Class: Response::RaiseError
- Inherits:
-
Middleware
- Object
- Middleware
- Response::RaiseError
- Defined in:
- lib/faraday/raise_error.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app) ⇒ RaiseError
constructor
A new instance of RaiseError.
Constructor Details
#initialize(app) ⇒ RaiseError
Returns a new instance of RaiseError.
31 32 33 |
# File 'lib/faraday/raise_error.rb', line 31 def initialize(app) super end |
Class Method Details
.register_on_complete(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/faraday/raise_error.rb', line 6 def self.register_on_complete(env) env[:response].on_complete do |response| case response[:status].to_i when 400 raise Octokit::BadRequest, (response) when 401 raise Octokit::Unauthorized, (response) when 403 raise Octokit::Forbidden, (response) when 404 raise Octokit::NotFound, (response) when 406 raise Octokit::NotAcceptable, (response) when 500 raise Octokit::InternalServerError, (response) when 501 raise Octokit::NotImplemented, (response) when 502 raise Octokit::BadGateway, (response) when 503 raise Octokit::ServiceUnavailable, (response) end end end |