Class: FaradayMiddleWare::RaiseFormi9HttpException
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleWare::RaiseFormi9HttpException
- Defined in:
- lib/faraday/raise_formi9_http_exception.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RaiseFormi9HttpException
constructor
A new instance of RaiseFormi9HttpException.
Constructor Details
#initialize(app) ⇒ RaiseFormi9HttpException
Returns a new instance of RaiseFormi9HttpException.
5 6 7 |
# File 'lib/faraday/raise_formi9_http_exception.rb', line 5 def initialize(app) super(app) end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/faraday/raise_formi9_http_exception.rb', line 9 def call(env) @app.call(env).on_complete do |response| case response.status.to_i when 400 raise Formi9::BadRequest.new(response) when 401 raise Formi9::Unauthorized.new(response) when 404 raise Formi9::NotFound.new(response) when 500 raise Formi9::InternalServerError.new(response) when 502 raise Formi9::BadGateway.new(response) when 503 raise Formi9::ServiceUnavailable.new(response) when 504 raise Formi9::GatewayTimeout.new(response) end end end |