feat: better error messages
This commit is contained in:
23
pkg/trace/trace.go
Normal file
23
pkg/trace/trace.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package trace
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Indent(s string, size int) string {
|
||||
lines := strings.Lines(s)
|
||||
indent := strings.Repeat(" ", size)
|
||||
|
||||
indented := ""
|
||||
for line := range lines {
|
||||
indented += indent + line
|
||||
}
|
||||
|
||||
return indented
|
||||
}
|
||||
|
||||
func WrapError(parent error, child error) error {
|
||||
childErrString := Indent(child.Error(), 4)
|
||||
return errors.New(parent.Error() + "\n" + childErrString)
|
||||
}
|
||||
Reference in New Issue
Block a user