errorIf(): Convert context canceled to canceling upon request (#3463)

This commit is contained in:
Anis Elleuch
2020-11-06 09:37:59 -08:00
committed by GitHub
parent 40e328eac2
commit 0289d32164
+7 -1
View File
@@ -158,7 +158,13 @@ func errorIf(err *probe.Error, msg string, data ...interface{}) {
}
msg = fmt.Sprintf(msg, data...)
if !globalDebug {
console.Errorln(fmt.Sprintf("%s %s", msg, err.ToGoError()))
e := err.ToGoError()
if errors.Is(e, context.Canceled) {
// This will replace context canceled error message
// that the user is seeing to a better one.
e = errors.New("Canceling upon user request")
}
console.Errorln(fmt.Sprintf("%s %s", msg, e))
return
}
console.Errorln(fmt.Sprintf("%s %s", msg, err))