mirror of
https://github.com/helm/helm.git
synced 2026-08-09 01:21:20 +00:00
refactor: prevent duplicates being inserted rather than post-filtering
Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
This commit is contained in:
@@ -379,6 +379,9 @@ func cleanupExecError(filename string, err error) error {
|
||||
if current == nil {
|
||||
break
|
||||
}
|
||||
if i == maxIterations-1 {
|
||||
return err
|
||||
}
|
||||
|
||||
var traceable TraceableError
|
||||
if execErrFmt.MatchString(current.Error()) {
|
||||
@@ -409,34 +412,24 @@ func cleanupExecError(filename string, err error) error {
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
if len(fileLocations) > 0 {
|
||||
lastErr := fileLocations[len(fileLocations)-1]
|
||||
if lastErr.message == traceable.message &&
|
||||
lastErr.location == traceable.location &&
|
||||
lastErr.executedFunction == traceable.executedFunction {
|
||||
current = errors.Unwrap(current)
|
||||
continue
|
||||
}
|
||||
}
|
||||
fileLocations = append(fileLocations, traceable)
|
||||
current = errors.Unwrap(current)
|
||||
}
|
||||
if current != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var prev TraceableError
|
||||
for i := len(fileLocations) - 1; i >= 0; i-- {
|
||||
current := fileLocations[i]
|
||||
if i == len(fileLocations)-1 {
|
||||
prev = current
|
||||
continue
|
||||
}
|
||||
|
||||
if current.message == prev.message && current.location == prev.location && current.executedFunction == prev.executedFunction {
|
||||
fileLocations[i].message = ""
|
||||
}
|
||||
prev = current
|
||||
}
|
||||
|
||||
finalErrorString := ""
|
||||
for _, fileLocation := range fileLocations {
|
||||
if fileLocation.message == "" {
|
||||
continue
|
||||
}
|
||||
finalErrorString = finalErrorString + fileLocation.String()
|
||||
}
|
||||
|
||||
if strings.TrimSpace(finalErrorString) == "" {
|
||||
// Fallback to original error message if nothing was extracted
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user