Class: ActiveSupport::ErrorReporter::ErrorContextMiddlewareStack
- Defined in:
- lib/active_support/error_reporter.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#execute(error, handled:, severity:, context:, source:) ⇒ Object
Run all middlewares in the stack.
-
#initialize ⇒ ErrorContextMiddlewareStack
constructor
A new instance of ErrorContextMiddlewareStack.
-
#use(middleware) ⇒ Object
Add a middleware to the error context stack.
Constructor Details
#initialize ⇒ ErrorContextMiddlewareStack
Returns a new instance of ErrorContextMiddlewareStack.
299 300 301 |
# File 'lib/active_support/error_reporter.rb', line 299 def initialize @stack = [] end |
Instance Method Details
#execute(error, handled:, severity:, context:, source:) ⇒ Object
Run all middlewares in the stack
313 314 315 |
# File 'lib/active_support/error_reporter.rb', line 313 def execute(error, handled:, severity:, context:, source:) @stack.inject(context) { |c, middleware| middleware.call(error, context: c, handled:, severity:, source:) } end |
#use(middleware) ⇒ Object
Add a middleware to the error context stack.
304 305 306 307 308 309 310 |
# File 'lib/active_support/error_reporter.rb', line 304 def use(middleware) unless middleware.respond_to?(:call) raise ArgumentError, "Error context middleware must respond to #call" end @stack << middleware end |