Exception: Cotoha::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Cotoha::Error
- Defined in:
- lib/cotoha/error.rb
Direct Known Subclasses
BadGateway, BadRequest, ClientError, Forbidden, InternalServerError, NotFound, ServerError, ServiceUnavailable, Unauthorized
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.
20 21 22 23 |
# File 'lib/cotoha/error.rb', line 20 def initialize(response = nil) @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 17 18 |
# File 'lib/cotoha/error.rb', line 3 def self.from_response(response) klass = case response.status when 400 then BadRequest when 401 then Unauthorized when 403 then Forbidden when 404 then NotFound when 400..499 then ClientError when 500 then InternalServerError when 502 then BadGateway when 503 then ServiceUnavailable when 500..599 then ServerError else nil end klass.new(response) if klass end |