Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 8fecb95

Browse files
committed
gps: fix unwrapVcsErr to handle nil causes
1 parent 062d2d0 commit 8fecb95

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

internal/gps/source_errors.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ import (
1313
// preserving the actual vcs command output and error, in addition to the message.
1414
// All other types pass through unchanged.
1515
func unwrapVcsErr(err error) error {
16+
var cause error
17+
var out, msg string
18+
1619
switch t := err.(type) {
1720
case *vcs.LocalError:
18-
cause, out, msg := t.Original(), t.Out(), t.Error()
19-
return errors.Wrap(errors.Wrap(cause, out), msg)
21+
cause, out, msg = t.Original(), t.Out(), t.Error()
2022
case *vcs.RemoteError:
21-
cause, out, msg := t.Original(), t.Out(), t.Error()
22-
return errors.Wrap(errors.Wrap(cause, out), msg)
23+
cause, out, msg = t.Original(), t.Out(), t.Error()
24+
2325
default:
2426
return err
2527
}
28+
29+
if cause == nil {
30+
cause = errors.New(out)
31+
} else {
32+
cause = errors.Wrap(cause, out)
33+
}
34+
return errors.Wrap(cause, msg)
2635
}

0 commit comments

Comments
 (0)