Skip to content

Commit

Permalink
refactor: Let GH driver return scm.ErrNotFound.
Browse files Browse the repository at this point in the history
Support consistent error handling across providers when it comes to
resources that could not be found.
fake driver already behaves correspondingly. However since it does not
return a HTTP response it is not possible to have one condition for
a 'not found' error that works for both providers. This PR makes that
possible now.
  • Loading branch information
mgoltzsche committed Apr 8, 2020
1 parent 486bc37 commit d6ede3c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scm/driver/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ func (c *wrapper) doRequest(ctx context.Context, req *scm.Request, in, out inter
// if an error is encountered, unmarshal and return the
// error response.
if res.Status > 300 {
if res.Status == 404 {
return res, scm.ErrNotFound
}
err := new(Error)
json.NewDecoder(res.Body).Decode(err)
return res, err
Expand Down

0 comments on commit d6ede3c

Please sign in to comment.