Class: Response::RaiseHttpErrors
- Inherits:
-
Middleware
- Object
- Middleware
- Response::RaiseHttpErrors
- Defined in:
- lib/faraday/response/raise_http_errors.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app) ⇒ RaiseHttpErrors
constructor
A new instance of RaiseHttpErrors.
Constructor Details
#initialize(app) ⇒ RaiseHttpErrors
Returns a new instance of RaiseHttpErrors.
26 27 28 29 |
# File 'lib/faraday/response/raise_http_errors.rb', line 26 def initialize(app) super @parser = nil end |
Class Method Details
.register_on_complete(env) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/faraday/response/raise_http_errors.rb', line 3 def self.register_on_complete(env) env[:response].on_complete do |response| case response[:status].to_i when 400 raise TropoRest::BadRequest, (response) when 401 raise TropoRest::NotAuthorized, (response) when 403 raise TropoRest::AccessDenied, (response) when 404 raise TropoRest::NotFound, (response) when 405 raise TropoRest::MethodNotAllowed, (response) when 415 raise TropoRest::UnsupportedMediaType, (response) when 500 raise TropoRest::InternalServerError, (response) when 503 raise TropoRest::ServiceUnavailable, (response) end end end |