better op names + fixing issue with op chaining in errors

This commit is contained in:
Julien Neuhart
2019-07-08 10:28:43 +02:00
parent 5f6ab2fc08
commit 5af01505c2
11 changed files with 74 additions and 64 deletions

View File

@@ -82,7 +82,6 @@ func Message(err error) string {
// Op returns the logical operation of the error, if available.
// Otherwise returns an empty string.
// FIXME: "resource.ChromePrinterOptions: float64: : "
func Op(err error) string {
if err == nil {
return ""
@@ -93,12 +92,10 @@ func Op(err error) string {
}
var buf bytes.Buffer
if e.Op != "" {
fmt.Fprintf(&buf, "%s: ", e.Op)
fmt.Fprintf(&buf, "%s", e.Op)
}
if e.Err != nil {
if wrappedOp := Op(e.Err); wrappedOp != "" {
fmt.Fprintf(&buf, "%s: ", wrappedOp)
}
if nestedOp := Op(e.Err); nestedOp != "" {
fmt.Fprintf(&buf, ": %s", nestedOp)
}
return buf.String()
}