Class: ActiveSupport::ErrorReporter::ErrorContextMiddlewareStack
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/error_reporter.rb |
Class Method Summary
- .new ⇒ ErrorContextMiddlewareStack constructor
Instance Method Summary
-
#execute(error, handled:, severity:, context:, source:)
Run all middlewares in the stack.
-
#use(middleware)
Add a middleware to the error context stack.
Constructor Details
.new ⇒ ErrorContextMiddlewareStack
# File 'activesupport/lib/active_support/error_reporter.rb', line 301
def initialize @stack = [] end
Instance Method Details
#execute(error, handled:, severity:, context:, source:)
Run all middlewares in the stack
# File 'activesupport/lib/active_support/error_reporter.rb', line 315
def execute(error, handled:, severity:, context:, source:) @stack.inject(context) { |c, middleware| middleware.call(error, context: c, handled:, severity:, source:) } end
#use(middleware)
Add a middleware to the error context stack.
# File 'activesupport/lib/active_support/error_reporter.rb', line 306
def use(middleware) unless middleware.respond_to?(:call) raise ArgumentError, "Error context middleware must respond to #call" end @stack << middleware end