mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00
fix: correct error formatting for error builder
This commit is contained in:
parent
4d030d2e16
commit
e823172c31
1 changed files with 6 additions and 5 deletions
|
@ -72,15 +72,14 @@ func (err *nestedError) Error() string {
|
|||
return makeLine("<nil>", 0)
|
||||
}
|
||||
|
||||
lines := make([]string, 0, 1+len(err.Extras))
|
||||
if err.Err != nil {
|
||||
lines := make([]string, 0, 1+len(err.Extras))
|
||||
lines = append(lines, makeLine(err.Err.Error(), 0))
|
||||
lines = append(lines, makeLines(err.Extras, 1)...)
|
||||
} else {
|
||||
lines = append(lines, makeLines(err.Extras, 0)...)
|
||||
}
|
||||
return strutils.JoinLines(lines)
|
||||
}
|
||||
return strutils.JoinLines(makeLines(err.Extras, 0))
|
||||
}
|
||||
|
||||
//go:inline
|
||||
func makeLine(err string, level int) string {
|
||||
|
@ -103,8 +102,10 @@ func makeLines(errs []error, level int) []string {
|
|||
case *nestedError:
|
||||
if err.Err != nil {
|
||||
lines = append(lines, makeLine(err.Err.Error(), level))
|
||||
}
|
||||
lines = append(lines, makeLines(err.Extras, level+1)...)
|
||||
} else {
|
||||
lines = append(lines, makeLines(err.Extras, level)...)
|
||||
}
|
||||
default:
|
||||
lines = append(lines, makeLine(err.Error(), level))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue