@cryptotaxi247 / kubo / commits / 6f76129b8

Simplify context canceled err message

License: MIT Signed-off-by: rht <rhtbot@gmail.com>

rht committed Jan 30, 2016 at 10:26 UTC 6f76129b8796701363c5fa9c3e072cb5cb7669e8
1 file changed +9 -1
cmd/ipfs/main.go
+9 -1
@@ -39,6 +39,7 @@ var log = logging.Logger("cmd/ipfs")
39 var (
40 errUnexpectedApiOutput = errors.New("api returned unexpected output")
41 errApiVersionMismatch = errors.New("api version mismatch")
42 + errRequestCanceled = errors.New("request canceled")
43 )
44
45 const (
@@ -328,7 +329,7 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd
329 if isConnRefused(err) {
330 err = repo.ErrApiNotRunning
331 }
331 - return nil, err
332 + return nil, wrapContextCanceled(err)
333 }
334
335 } else {
@@ -625,3 +626,10 @@ func isConnRefused(err error) bool {
626
627 return netoperr.Op == "dial"
628 }
629 +
630 +func wrapContextCanceled(err error) error {
631 + if strings.Contains(err.Error(), "request canceled") {
632 + err = errRequestCanceled
633 + }
634 + return err
635 +}