Class: Response::RaiseOctokitError

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/response/raise_octokit_error.rb

Constant Summary collapse

ERROR_MAP =
{
  400 => Octokit::BadRequest,
  401 => Octokit::Unauthorized,
  403 => Octokit::Forbidden,
  404 => Octokit::NotFound,
  406 => Octokit::NotAcceptable,
  422 => Octokit::UnprocessableEntity,
  500 => Octokit::InternalServerError,
  501 => Octokit::NotImplemented,
  502 => Octokit::BadGateway,
  503 => Octokit::ServiceUnavailable
}

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object

Raises:



20
21
22
23
# File 'lib/faraday/response/raise_octokit_error.rb', line 20

def on_complete(response)
  key = response[:status].to_i
  raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
end