lfsapi/errors.go: create a NewUnprocessableEntityError when appropriate
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.
This commit is contained in:
parent
013c02d010
commit
40929cc7f0
@ -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)
|
||||
}
|
||||
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user