Show a better err msg when Control-C is hit (#3446)

Currently the error message is "context canceled" which is cryptic
This commit is contained in:
Anis Elleuch
2020-10-08 11:46:11 -07:00
committed by GitHub
parent 0324fdcc6e
commit bb2bfdc918
+9 -1
View File
@@ -17,6 +17,8 @@
package cmd
import (
"context"
"errors"
"fmt"
"strings"
"unicode"
@@ -81,7 +83,13 @@ func fatal(err *probe.Error, msg string, data ...interface{}) {
msg = fmt.Sprintf(msg, data...)
errmsg := err.String()
if !globalDebug {
errmsg = err.ToGoError().Error()
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")
}
errmsg = e.Error()
}
// Remove unnecessary leading spaces in generic/detailed error messages