Class: FaradayMiddleware::RaiseHttpException
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleware::RaiseHttpException
- Defined in:
- lib/faraday/raise_http_exception.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RaiseHttpException
constructor
A new instance of RaiseHttpException.
Constructor Details
#initialize(app) ⇒ RaiseHttpException
Returns a new instance of RaiseHttpException.
18 19 20 21 |
# File 'lib/faraday/raise_http_exception.rb', line 18 def initialize(app) super app @parser = nil end |
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/faraday/raise_http_exception.rb', line 5 def call(env) @app.call(env).on_complete do |response| case response[:status].to_i when 400 raise Scalingo::BadRequest, (response) when 404 raise Scalingo::NotFound, (response) when 500 raise Scalingo::InternalServerError, (response, "Something is technically wrong.") end end end |