Class: FaradayMiddleware::RaiseHttpException
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleware::RaiseHttpException
- Defined in:
- lib/faraday/raise_error.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
Handle response codes 401, 404 and 500 as exceptions.
Instance Method Details
#call(env) ⇒ Object
Handle response codes 401, 404 and 500 as exceptions. See github.com/technoweenie/faraday#writing-middleware for more details.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/faraday/raise_error.rb', line 9 def call(env) @app.call(env).on_complete do |response| case response[:status].to_i when 401 raise Citrulu::AccessDenied, (response) when 404 raise Citrulu::NotFound, (response) when 500 raise Citrulu::InternalServerError, (response, "Something is technically wrong.") end end end |