lib/gitlab/request.rb in gitlab-4.11.0 vs lib/gitlab/request.rb in gitlab-4.12.0
- old
+ new
@@ -48,23 +48,10 @@
end
# Checks the response code for common errors.
# Returns parsed response for successful requests.
def validate(response)
- error_klass = case response.code
- when 400 then Error::BadRequest
- when 401 then Error::Unauthorized
- when 403 then Error::Forbidden
- when 404 then Error::NotFound
- when 405 then Error::MethodNotAllowed
- when 409 then Error::Conflict
- when 422 then Error::Unprocessable
- when 429 then Error::TooManyRequests
- when 500 then Error::InternalServerError
- when 502 then Error::BadGateway
- when 503 then Error::ServiceUnavailable
- end
-
+ error_klass = Error::STATUS_MAPPINGS[response.code]
raise error_klass, response if error_klass
parsed = response.parsed_response
parsed.client = self if parsed.respond_to?(:client=)
parsed.parse_headers!(response.headers) if parsed.respond_to?(:parse_headers!)