зеркало из https://github.com/golang/dep.git
Коммит
a87f8cc784
|
@ -5,20 +5,21 @@
|
||||||
package gps
|
package gps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/Masterminds/vcs"
|
"github.com/Masterminds/vcs"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// unwrapVcsErr will extract actual command output from a vcs err, if possible
|
// unwrapVcsErr recognizes *vcs.LocalError and *vsc.RemoteError, and returns a form
|
||||||
//
|
// preserving the actual vcs command output and error, in addition to the message.
|
||||||
// TODO this is really dumb, lossy, and needs proper handling
|
// All other types pass through unchanged.
|
||||||
func unwrapVcsErr(err error) error {
|
func unwrapVcsErr(err error) error {
|
||||||
switch verr := err.(type) {
|
switch t := err.(type) {
|
||||||
case *vcs.LocalError:
|
case *vcs.LocalError:
|
||||||
return fmt.Errorf("%s: %s", verr.Error(), verr.Out())
|
cause, out, msg := t.Original(), t.Out(), t.Error()
|
||||||
|
return errors.Wrap(errors.Wrap(cause, out), msg)
|
||||||
case *vcs.RemoteError:
|
case *vcs.RemoteError:
|
||||||
return fmt.Errorf("%s: %s", verr.Error(), verr.Out())
|
cause, out, msg := t.Original(), t.Out(), t.Error()
|
||||||
|
return errors.Wrap(errors.Wrap(cause, out), msg)
|
||||||
default:
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче