instance method
add_middleware
Ruby on Rails 8.1.2
Since v8.1.2Signature
add_middleware(middleware)
Add a middleware to modify the error context before it is sent to subscribers.
Middleware is added to a stack of callables run on an error’s execution context before passing to subscribers. Allows creation of entries in error context that are shared by all subscribers.
A context middleware receives the same parameters as #report. It must return a hash - the middleware stack returns the hash after it has run through all middlewares. A middleware can mutate or replace the hash.
Rails.error.add_middleware(-> (error, context) { context.merge({ foo: :bar }) })
Parameters
-
middlewarereq
Source
# File activesupport/lib/active_support/error_reporter.rb, line 218
def add_middleware(middleware)
@context_middlewares.use(middleware)
end
Defined in activesupport/lib/active_support/error_reporter.rb line 218
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::ErrorReporter