Class: Strava::Web::Response::RaiseError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Strava::Web::Response::RaiseError
- Defined in:
- lib/strava/web/raise_error.rb
Constant Summary collapse
- ClientErrorStatuses =
(400...600).freeze
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/strava/web/raise_error.rb', line 7 def on_complete(env) case env[:status] when 404 raise Faraday::Error::ResourceNotFound, response_values(env) when 407 # mimic the behavior that we get with proxy requests with HTTPS raise Faraday::Error::ConnectionFailed, %(407 "Proxy Authentication Required ") when ClientErrorStatuses raise Strava::Errors::Fault, response_values(env) end end |
#response_values(env) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/strava/web/raise_error.rb', line 19 def response_values(env) { status: env.status, headers: env.response_headers, body: env.body } end |