Class: Response::RaiseGheeError

Inherits:
Middleware
  • Object
show all
Defined in:
lib/ghee/errors.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object

Raises:



89
90
91
92
# File 'lib/ghee/errors.rb', line 89

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