Exception: Frontapp::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Frontapp::Error
- Defined in:
- lib/frontapp/error.rb
Direct Known Subclasses
BadRequestError, ConflictError, NotFoundError, TooManyRequestsError, UnauthorizedError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
15 16 17 18 |
# File 'lib/frontapp/error.rb', line 15 def initialize(response) @response = response super("Response: #{response.inspect}\nBody: #{response.body}") end |
Class Method Details
.from_response(response) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/frontapp/error.rb', line 3 def self.from_response(response) error_class = case response.status when 400 then BadRequestError when 401 then UnauthorizedError when 404 then NotFoundError when 409 then ConflictError when 429 then TooManyRequestsError else self end error_class.new(response) end |