Class: HTTP::Features::RaiseError
- Inherits:
-
HTTP::Feature
- Object
- HTTP::Feature
- HTTP::Features::RaiseError
- Defined in:
- lib/http/features/raise_error.rb
Overview
Raises an error for non-successful HTTP responses
Instance Method Summary collapse
-
#initialize(ignore: []) ⇒ RaiseError
constructor
Initializes the RaiseError feature.
-
#wrap_response(response) ⇒ HTTP::Response
Raises an error for non-successful responses.
Methods inherited from HTTP::Feature
#around_request, #on_error, #on_request, #wrap_request
Constructor Details
#initialize(ignore: []) ⇒ RaiseError
Initializes the RaiseError feature
15 16 17 |
# File 'lib/http/features/raise_error.rb', line 15 def initialize(ignore: []) @ignore = ignore end |
Instance Method Details
#wrap_response(response) ⇒ HTTP::Response
Raises an error for non-successful responses
27 28 29 30 31 32 |
# File 'lib/http/features/raise_error.rb', line 27 def wrap_response(response) return response if response.code < 400 return response if @ignore.include?(response.code) raise StatusError, response end |