Exception: Simplewoo::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Simplewoo::Error
- Defined in:
- lib/simplewoo/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
20 21 22 23 |
# File 'lib/simplewoo/error.rb', line 20 def initialize(response) @response = response super() end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/simplewoo/error.rb', line 4 def response @response end |
Class Method Details
.from(response) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/simplewoo/error.rb', line 6 def self.from(response) status = response.status if klass = case status when 400 then Simplewoo::BadRequest when 401 then Simplewoo:: when 404 then Simplewoo::NotFound when 422 then Simplewoo::UnprocessableEntity end klass.new(response) end end |
Instance Method Details
#errors ⇒ Object
25 26 27 |
# File 'lib/simplewoo/error.rb', line 25 def errors response.body end |