Module: Gitlab::Error

Defined in:
lib/gitlab/error.rb

Defined Under Namespace

Classes: BadGateway, BadRequest, Conflict, ConnectionTimedOut, Error, Forbidden, InternalServerError, MethodNotAllowed, MissingCredentials, NotAcceptable, NotFound, Parsing, ResponseError, ServiceUnavailable, TooManyRequests, Unauthorized, Unprocessable

Constant Summary collapse

STATUS_MAPPINGS =
{
  400 => BadRequest,
  401 => Unauthorized,
  403 => Forbidden,
  404 => NotFound,
  405 => MethodNotAllowed,
  406 => NotAcceptable,
  409 => Conflict,
  422 => Unprocessable,
  429 => TooManyRequests,
  500 => InternalServerError,
  502 => BadGateway,
  503 => ServiceUnavailable,
  522 => ConnectionTimedOut
}.freeze

Class Method Summary collapse

Class Method Details

.klass(response) ⇒ Object



107
108
109
110
111
112
# File 'lib/gitlab/error.rb', line 107

def self.klass(response)
  error_klass = STATUS_MAPPINGS[response.status]
  return error_klass if error_klass

  ResponseError if response.status >= 400
end