method

add_middleware

rails latest stable - Class: ActiveSupport::ErrorReporter

Method not available on this version

This method is only available on newer versions. The first available version (v8.1.1) is shown here.

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