Skip to content

Commit

Permalink
lfsapi/errors.go: create a NewUnprocessableEntityError when appropriate
Browse files Browse the repository at this point in the history
In the previous commit, we introduced a new type for detecting when the
server sent back an HTTP 422.

In this commit, let's use that and detect when we get a situation in
which:

    res.StatusCode == 422

And create+return the new error appropriately.
  • Loading branch information
ttaylorr committed Jul 31, 2018
1 parent 013c02d commit 40929cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lfsapi/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (c *Client) handleResponse(res *http.Response) error {
return errors.NewAuthError(err)
}

if res.StatusCode == 422 {
return errors.NewUnprocessableEntityError(err)
}

if res.StatusCode > 499 && res.StatusCode != 501 && res.StatusCode != 507 && res.StatusCode != 509 {
return errors.NewFatalError(err)
}
Expand Down Expand Up @@ -92,6 +96,7 @@ var (
401: "Authorization error: %s\nCheck that you have proper access to the repository",
403: "Authorization error: %s\nCheck that you have proper access to the repository",
404: "Repository or object not found: %s\nCheck that it exists and that you have proper access to it",
422: "Unprocessable entity: %s",
429: "Rate limit exceeded: %s",
500: "Server error: %s",
501: "Not Implemented: %s",
Expand Down
8 changes: 0 additions & 8 deletions t/t-push-failures-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ begin_test "push: upload file with storage 410"
)
end_test

begin_test "push: upload file with storage 422"
(
set -e

push_fail_test "status-storage-422"
)
end_test

begin_test "push: upload file with storage 500"
(
set -e
Expand Down

0 comments on commit 40929cc

Please sign in to comment.