fix nil being passed to errors.Wrap()

Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
Jess Frazelle 2016-12-19 17:03:47 -08:00 коммит произвёл Edward Muller
Родитель 5b2ff11262
Коммит 685d5fc0f0
3 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -111,6 +111,7 @@ func (cmd *ensureCommand) Run(args []string) error {
pc, err := getProjectConstraint(arg, sm) pc, err := getProjectConstraint(arg, sm)
if err != nil { if err != nil {
errs = append(errs, err) errs = append(errs, err)
continue
} }
if gps.IsAny(pc.Constraint) && pc.Ident.Source == "" { if gps.IsAny(pc.Constraint) && pc.Ident.Source == "" {
@ -145,6 +146,7 @@ func (cmd *ensureCommand) Run(args []string) error {
pc, err := getProjectConstraint(ovr, sm) pc, err := getProjectConstraint(ovr, sm)
if err != nil { if err != nil {
errs = append(errs, err) errs = append(errs, err)
continue
} }
// Empty overrides are fine (in contrast to deps), because they actually // Empty overrides are fine (in contrast to deps), because they actually
@ -166,7 +168,7 @@ func (cmd *ensureCommand) Run(args []string) error {
if len(errs) > 0 { if len(errs) > 0 {
var buf bytes.Buffer var buf bytes.Buffer
for err := range errs { for _, err := range errs {
fmt.Fprintln(&buf, err) fmt.Fprintln(&buf, err)
} }
@ -293,7 +295,7 @@ func getProjectConstraint(arg string, sm *gps.SourceMgr) (gps.ProjectConstraint,
} }
if string(pr) != arg { if string(pr) != arg {
return constraint, errors.Wrapf(err, "dependency path %s is not a project root", arg) return constraint, fmt.Errorf("dependency path %s is not a project root, try %s instead", arg, pr)
} }
constraint.Ident.ProjectRoot = gps.ProjectRoot(arg) constraint.Ident.ProjectRoot = gps.ProjectRoot(arg)

Просмотреть файл

@ -138,7 +138,7 @@ func resetUsage(fs *flag.FlagSet, name, args, longHelp string) {
} }
var ( var (
errProjectNotFound = errors.New("no project could be found") errProjectNotFound = errors.New("could not find project manifest.json")
) )
func findProjectRootFromWD() (string, error) { func findProjectRootFromWD() (string, error) {

Просмотреть файл

@ -150,7 +150,7 @@ func toPossible(pp gps.ProjectProperties) (p possibleProps) {
// the 'any' case, because that's the other possibility, and it's what // the 'any' case, because that's the other possibility, and it's what
// we interpret not having any constraint expressions at all to mean. // we interpret not having any constraint expressions at all to mean.
//if !gps.IsAny(pp.Constraint) && !gps.IsNone(pp.Constraint) { //if !gps.IsAny(pp.Constraint) && !gps.IsNone(pp.Constraint) {
if !gps.IsAny(pp.Constraint) { if !gps.IsAny(pp.Constraint) && pp.Constraint != nil {
// Has to be a semver range. // Has to be a semver range.
p.Version = pp.Constraint.String() p.Version = pp.Constraint.String()
} }