Class: Response::RaiseHttp4xx
- Inherits:
-
Middleware
- Object
- Middleware
- Response::RaiseHttp4xx
- Defined in:
- lib/faraday/raise_http_4xx.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app) ⇒ RaiseHttp4xx
constructor
A new instance of RaiseHttp4xx.
Constructor Details
#initialize(app) ⇒ RaiseHttp4xx
Returns a new instance of RaiseHttp4xx.
26 27 28 29 |
# File 'lib/faraday/raise_http_4xx.rb', line 26 def initialize(app) super @parser = nil end |
Class Method Details
.register_on_complete(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/faraday/raise_http_4xx.rb', line 7 def self.register_on_complete(env) env[:response].on_complete do |response| case response[:status].to_i when 400 raise Slideshare::BadRequest, (response) when 401 raise Slideshare::Unauthorized, (response) when 403 raise Slideshare::Forbidden, (response) when 404 raise Slideshare::NotFound, (response) when 406 raise Slideshare::NotAcceptable, (response) when 420 raise Slideshare::EnhanceYourCalm.new (response), response[:response_headers] end end end |