Class: ElephantInTheRoom::TheOneApiSdk::Pipeline::RaiseHttpErrors
- Inherits:
-
Object
- Object
- ElephantInTheRoom::TheOneApiSdk::Pipeline::RaiseHttpErrors
- Defined in:
- lib/elephant_in_the_room/the_one_api_sdk/pipeline/raise_http_errors.rb
Overview
Pipeline stage that raises errors when the HTTP response is a 4xx or 5xx error
Instance Method Summary collapse
- #execute_http_request(request_details) ⇒ Object
- #http_response ⇒ Object
-
#initialize(next_pipeline_stage) ⇒ RaiseHttpErrors
constructor
A new instance of RaiseHttpErrors.
Constructor Details
#initialize(next_pipeline_stage) ⇒ RaiseHttpErrors
9 10 11 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/raise_http_errors.rb', line 9 def initialize(next_pipeline_stage) @next_pipeline_stage = next_pipeline_stage end |
Instance Method Details
#execute_http_request(request_details) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/raise_http_errors.rb', line 13 def execute_http_request(request_details) response = @next_pipeline_stage.execute_http_request(request_details) if response.is_a? Net::HTTPServerError raise ElephantInTheRoom::TheOneApiSdk::Errors::ServerError, response elsif response.is_a? Net::HTTPClientError raise ElephantInTheRoom::TheOneApiSdk::Errors::ClientError, response end end |
#http_response ⇒ Object
22 23 24 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/raise_http_errors.rb', line 22 def http_response @next_pipeline_stage.http_response end |