Exception: Traitify::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Traitify::Error
- Defined in:
- lib/traitify/error.rb
Direct Known Subclasses
BadRequest, NotFound, ServerError, Unauthorized, UnprocessableEntity
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
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.
17 18 19 20 21 |
# File 'lib/traitify/error.rb', line 17 def initialize(response) @response = response super() end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/traitify/error.rb', line 3 def response @response end |
Class Method Details
.from(response) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/traitify/error.rb', line 5 def self.from(response) klass = case response.status when 400 then Traitify::BadRequest when 401 then Traitify::Unauthorized when 404 then Traitify::NotFound when 422 then Traitify::UnprocessableEntity when 500..505 then Traitify::ServerError end klass.new(response) if klass end |