Exception: Breacan::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Breacan::Error
- Defined in:
- lib/breacan/error.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(response = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response = nil) ⇒ Error
Returns a new instance of Error.
24 25 26 27 |
# File 'lib/breacan/error.rb', line 24 def initialize(response = nil) @response = response super() end |
Class Method Details
.from_body(body) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/breacan/error.rb', line 3 def self.from_body(body) if klass = case body[:error] when 400 then Breacan::BadRequest when 401 then Breacan::Unauthorized when 403 then Breacan::Forbidden when 404 then Breacan::NotFound when 406 then Breacan::NotAcceptable when 409 then Breacan::Conflict when 415 then Breacan::UnsupportedMediaType when 422 then Breacan::UnprocessableEntity when 400..499 then Breacan::ClientError when 500 then Breacan::InternalServerError when 501 then Breacan::NotImplemented when 502 then Breacan::BadGateway when 503 then Breacan::ServiceUnavailable when 500..599 then Breacan::ServerError end klass.new(response) end end |
Instance Method Details
#errors ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/breacan/error.rb', line 29 def errors if data && data.is_a?(Hash) data[:errors] || [] else [] end end |