Exception: Ribose::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Ribose::Error
- Defined in:
- lib/ribose/error.rb
Direct Known Subclasses
BadRequest, Forbidden, NotFound, ServerError, Unauthorized, UnprocessableEntity
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response = nil) ⇒ Error
Returns a new instance of Error.
3 4 5 6 |
# File 'lib/ribose/error.rb', line 3 def initialize(response = nil) @response = response super end |
Class Method Details
.from_response(response) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ribose/error.rb', line 8 def self.from_response(response) status = response[:status].to_i if klass = case status when 400 then Ribose::BadRequest when 401 then Ribose::Unauthorized when 403 then Ribose::Forbidden when 404 then Ribose::NotFound when 422 then Ribose::UnprocessableEntity when 500..599 then Ribose::ServerError end klass.new(response) end end |