зеркало из https://github.com/golang/dep.git
gps: fix unwrapVcsErr to handle nil causes
This commit is contained in:
Родитель
062d2d0ef2
Коммит
8fecb95f63
|
@ -13,14 +13,23 @@ import (
|
|||
// preserving the actual vcs command output and error, in addition to the message.
|
||||
// All other types pass through unchanged.
|
||||
func unwrapVcsErr(err error) error {
|
||||
var cause error
|
||||
var out, msg string
|
||||
|
||||
switch t := err.(type) {
|
||||
case *vcs.LocalError:
|
||||
cause, out, msg := t.Original(), t.Out(), t.Error()
|
||||
return errors.Wrap(errors.Wrap(cause, out), msg)
|
||||
cause, out, msg = t.Original(), t.Out(), t.Error()
|
||||
case *vcs.RemoteError:
|
||||
cause, out, msg := t.Original(), t.Out(), t.Error()
|
||||
return errors.Wrap(errors.Wrap(cause, out), msg)
|
||||
cause, out, msg = t.Original(), t.Out(), t.Error()
|
||||
|
||||
default:
|
||||
return err
|
||||
}
|
||||
|
||||
if cause == nil {
|
||||
cause = errors.New(out)
|
||||
} else {
|
||||
cause = errors.Wrap(cause, out)
|
||||
}
|
||||
return errors.Wrap(cause, msg)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче