Class: IContact::ErrorHandler
- Inherits:
-
Object
- Object
- IContact::ErrorHandler
- Defined in:
- lib/icontact/errors.rb
Constant Summary collapse
- ERRORS =
{ 400 => IContact::BadRequest, 401 => IContact::NotAuthorized, 402 => IContact::PaymentRequest, 403 => IContact::Forbidden, 405 => IContact::MethodNotAllowed, 406 => IContact::NotAcceptable, 415 => IContact::UnsupportedMediaType, 500 => IContact::InternalServer, 501 => IContact::NotImplemented, 503 => IContact::ServiceUnavailable, 507 => IContact::InsufficientSpace }
Instance Method Summary collapse
-
#initialize(response) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
Constructor Details
#initialize(response) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/icontact/errors.rb', line 46 def initialize(response) error_class = ERRORS[response.status.to_i] = Oj.load(response.body)['errors'] if error_class raise error_class.new() else raise IContactError.new("#{response.status}: #{message}") end end |