Exception: Layer::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Layer::Error
show all
- Defined in:
- lib/layer/errors.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response) ⇒ Error
18
19
20
21
|
# File 'lib/layer/errors.rb', line 18
def initialize(response)
@response = response
super(build_error_message)
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
|