Exception: OpConnect::Error
- Inherits:
-
StandardError
- Object
- StandardError
- OpConnect::Error
- Defined in:
- lib/op_connect/error.rb
Direct Known Subclasses
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.
23 24 25 26 |
# File 'lib/op_connect/error.rb', line 23 def initialize(response = nil) @response = response super() end |
Class Method Details
.from_response(response) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/op_connect/error.rb', line 4 def from_response(response) status = response.status if (klass = case status when 400 then OpConnect::BadRequest when 401 then OpConnect::Unauthorized when 403 then OpConnect::Forbidden when 404 then OpConnect::NotFound when 413 then OpConnect::PayloadTooLarge when 400..499 then OpConnect::ClientError when 500 then OpConnect::InternalServerError when 503 then OpConnect::ServiceUnavailable when 500..599 then OpConnect::ServerError end) klass.new(response) end end |