Class: Tacokit::Middleware::RaiseError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Tacokit::Middleware::RaiseError
- Defined in:
- lib/tacokit/middleware/raise_error.rb
Constant Summary
- CLIENT_ERROR_STATUSES =
400...600
Instance Method Summary (collapse)
Instance Method Details
- (Object) error_message(env)
22 23 24 |
# File 'lib/tacokit/middleware/raise_error.rb', line 22 def (env) "Server returned #{env[:status]}: #{env.body}. Headers #{env.response_headers.inspect}" end |
- (Object) on_complete(env)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tacokit/middleware/raise_error.rb', line 6 def on_complete(env) case env[:status] when 401 raise Tacokit::Error::Unauthorized, (env) when 404 raise Tacokit::Error::ResourceNotFound, (env) when 407 # mimic the behavior that we get with proxy requests with HTTPS raise Tacokit::Error::ConnectionFailed, %(407 "Proxy Authentication Required ") when 408 raise Tacokit::Error::TimeoutError, (env) when CLIENT_ERROR_STATUSES raise Tacokit::Error::ClientError, (env) end end |