Exception: Layer::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Layer::Error
- Defined in:
- lib/layer/errors.rb
Direct Known Subclasses
Layer::Errors::BadRequest, Layer::Errors::Conflict, Layer::Errors::NotFound, Layer::Errors::ResourceDeleted, Layer::Errors::ServerError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
- #response ⇒ Object
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
18 19 20 21 |
# File 'lib/layer/errors.rb', line 18 def initialize(response) @response = response super() end |
Class Method Details
.from_response(response) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/layer/errors.rb', line 3 def self.from_response(response) status = response[:status] if klass = case status when 400 then Layer::Errors::BadRequest when 404 then Layer::Errors::NotFound when 409 then Layer::Errors::Conflict when 410 then Layer::Errors::ResourceDeleted when 500..599 then Layer::Errors::ServerError else self end klass.new(response) end end |
Instance Method Details
#response ⇒ Object
23 24 25 |
# File 'lib/layer/errors.rb', line 23 def response @response end |