method

add_middleware

add_middleware(middleware)
public

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 }) })