Exception: Housecanary::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Housecanary::Error
- Defined in:
- lib/housecanary/error.rb
Overview
:nodoc:
Constant Summary collapse
- NoContent =
Class.new(self)
- BadRequest =
Class.new(self)
Class.new(self)
- Forbidden =
Class.new(self)
- NotFound =
Class.new(self)
- InternalServerError =
Class.new(self)
- TooManyRequests =
Class.new(self)
- ERRORS_MAP =
{ 204 => Housecanary::Error::NoContent, 400 => Housecanary::Error::BadRequest, 401 => Housecanary::Error::Unauthorized, 403 => Housecanary::Error::Forbidden, 404 => Housecanary::Error::NotFound, 429 => Housecanary::Error::TooManyRequests, 500 => Housecanary::Error::InternalServerError }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/housecanary/error.rb', line 5 def code @code end |
Class Method Details
.from_response(body) ⇒ Object
26 27 28 29 |
# File 'lib/housecanary/error.rb', line 26 def from_response(body) , status = parse_error(body) new(, status) end |
.parse_error(body) ⇒ Object
31 32 33 34 35 |
# File 'lib/housecanary/error.rb', line 31 def parse_error(body) = body.fetch(:message, nil) || body.fetch(:api_code_description, nil) status = body.fetch(:status, nil) || body.fetch(:api_code, nil) [, status] end |