From 40929cc7f096180544cd9784ffc68bf69178d09b Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Tue, 31 Jul 2018 13:23:16 -0500 Subject: [PATCH] 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. --- lfsapi/errors.go | 5 +++++ t/t-push-failures-remote.sh | 8 -------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lfsapi/errors.go b/lfsapi/errors.go index dd9b64eedc..916633b169 100644 --- a/lfsapi/errors.go +++ b/lfsapi/errors.go @@ -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", diff --git a/t/t-push-failures-remote.sh b/t/t-push-failures-remote.sh index b5b6c8a015..358e72c3de 100755 --- a/t/t-push-failures-remote.sh +++ b/t/t-push-failures-remote.sh @@ -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