module UniversalGitClient::Http::ResponseValidation
Public Instance Methods
with_response_validation!() { || ... }
click to toggle source
# File lib/universal-git-client/http/response_validation.rb, line 8 def with_response_validation! response = yield case response.code when 200..399 then response when 400 then raise Errors::BadRequest.new('BadRequest', response) when 401 then raise Errors::Unauthorized.new('Unauthorized', response) when 403 then raise Errors::Forbidden.new('Forbidden', response) when 404 then raise Errors::NotFound.new('NotFound', response) when 405 then raise Errors::MethodNotAllowed.new('MethodNotAllowed', response) when 406 then raise Errors::NotAcceptable.new('NotAcceptable', response) when 409 then raise Errors::Conflict.new('Conflict', response) when 415 then raise Errors::UnsupportedMediaType.new('UnsupportedMediaType', response) when 422 then raise Errors::UnprocessableEntity.new('UnprocessableEntity', response) when 400..499 then raise Errors::ClientError.new('ClientError', response) when 500 then raise Errors::InternalServerError.new('InternalServerError', response) when 502 then raise Errors::BadGateway.new('BadGateway', response) when 503 then raise Errors::ServiceUnavailable.new('ServiceUnavailable', response) when 500..599 then raise Errors::ServerError.new('ServerError', response) end end