Print 'Cancel upon user request' when the global context is cancelled (#4406)

This commit is contained in:
Anis Elleuch
2022-12-16 23:26:04 -08:00
committed by GitHub
parent c24e9c7847
commit 7370e6bfd3
+10 -8
View File
@@ -84,11 +84,12 @@ func fatal(err *probe.Error, msg string, data ...interface{}) {
msg = fmt.Sprintf(msg, data...)
errmsg := err.String()
if !globalDebug {
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.
var e error
if errors.Is(globalContext.Err(), context.Canceled) {
// mc is getting killed
e = errors.New("Canceling upon user request")
} else {
e = err.ToGoError()
}
errmsg = e.Error()
}
@@ -159,11 +160,12 @@ func errorIf(err *probe.Error, msg string, data ...interface{}) {
}
msg = fmt.Sprintf(msg, data...)
if !globalDebug {
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.
var e error
if errors.Is(globalContext.Err(), context.Canceled) {
// mc is getting killed
e = errors.New("Canceling upon user request")
} else {
e = err.ToGoError()
}
console.Errorln(fmt.Sprintf("%s %s", msg, e))
return