Exception: Ivapi::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Ivapi::Error
- Defined in:
- lib/ivapi/error.rb
Direct Known Subclasses
Class Method Summary collapse
-
.from_response(response) ⇒ Object
Returns the appropriate Ivapi::Error sublcass based on status and response message.
Class Method Details
.from_response(response) ⇒ Object
Returns the appropriate Ivapi::Error sublcass based on status and response message.
response - The Hash of HTTP response.
Returns the Ivapi::Error.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ivapi/error.rb', line 11 def self.from_response(response) status = response[:status].to_i klass = case status when 400 then Ivapi::BadRequest when 401 then Ivapi::Unauthorized when 403 then Ivapi::Forbidden end klass&.new(response) end |