Class: Faraday::Response::RaiseError
- Inherits:
-
Middleware
- Object
- Middleware
- Middleware
- Faraday::Response::RaiseError
- Defined in:
- lib/faraday/response/raise_error.rb
Instance Method Summary collapse
Methods inherited from Middleware
Methods inherited from Middleware
adapter?, dependency, inherited, #initialize, loaded?, new
Methods included from MiddlewareRegistry
#lookup_middleware, #register_middleware
Constructor Details
This class inherits a constructor from Faraday::Middleware
Instance Method Details
#on_complete(env) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/faraday/response/raise_error.rb', line 3 def on_complete(env) case env[:status] when 404 raise Faraday::Error::ResourceNotFound, response_values(env) when 400...600 raise Faraday::Error::ClientError, response_values(env) end end |
#response_values(env) ⇒ Object
12 13 14 |
# File 'lib/faraday/response/raise_error.rb', line 12 def response_values(env) {:status => env[:status], :headers => env[:response_headers], :body => env[:body]} end |