Skip to content

Commit

Permalink
internal/gps: return an error instead of panicing
Browse files Browse the repository at this point in the history
solver.selectRoot() panics when solver.intersectConstraintsWithImports()
returns an error.

This commit returns the error instead if that error is due to inability
to deduce a project repository.

Solves golang#292 and golang#581

Signed-off-by: Ibrahim AshShohail <[email protected]>
  • Loading branch information
ibrasho committed Jun 6, 2017
1 parent ce194b4 commit c72bb5b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/gps/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ func (s *solver) selectRoot() error {
// analysis, rather than having the sm do it
deps, err := s.intersectConstraintsWithImports(s.rd.combineConstraints(), s.rd.externalImportList(s.stdLibFn))
if err != nil {
if strings.HasPrefix(err.Error(), "unable to deduce repository and source type for:") {
return err
}
// TODO(sdboyer) this could well happen; handle it with a more graceful error
panic(fmt.Sprintf("shouldn't be possible %s", err))
}
Expand Down

0 comments on commit c72bb5b

Please sign in to comment.