Class: PactBroker::Api::Resources::ErrorHandler
- Inherits:
-
Object
- Object
- PactBroker::Api::Resources::ErrorHandler
- Includes:
- Logging
- Defined in:
- lib/pact_broker/api/resources/error_handler.rb
Instance Method Summary collapse
- #call(error, env, message = nil) ⇒ Object
-
#initialize(error_logger, error_response_generator, error_reporter) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
Methods included from Logging
included, #log_error, #log_with_tag, #measure_info
Constructor Details
#initialize(error_logger, error_response_generator, error_reporter) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
14 15 16 17 18 |
# File 'lib/pact_broker/api/resources/error_handler.rb', line 14 def initialize(error_logger, error_response_generator, error_reporter) @error_logger = error_logger @error_response_generator = error_response_generator @error_reporter = error_reporter end |
Instance Method Details
#call(error, env, message = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pact_broker/api/resources/error_handler.rb', line 20 def call(error, env, = nil) error_reference = PactBroker::Errors.generate_error_reference # log error error_logger.call(error, error_reference, env) # report error error_reporter.call(error, error_reference, env) # generate response headers, body = error_response_generator.call(error, error_reference, env, message: ) headers.each { | key, value | response.headers[key] = value } return headers, body end |