class ActiveSupport::ErrorReporter

def handle(*error_classes, severity: :warning, context: {}, fallback: nil, source: DEFAULT_SOURCE)

errors. Defaults to "application".
source of the error. Subscribers can use this value to ignore certain
* +:source+ - This value is passed along to subscribers to indicate the

end
User.find_by(params)
user = Rails.error.handle(fallback: -> { User.anonymous }) do

unhandled error is raised. For example:
* +:fallback+ - A callable that provides +handle+'s return value when an

end
# ...
Rails.error.handle(context: { section: "admin" }) do

example:
* +:context+ - Extra information that is passed along to subscribers. For

Defaults to +:warning+.
important the error report is. Can be +:error+, +:warning+, or +:info+.
* +:severity+ - This value is passed along to subscribers to indicate how

==== Options

maybe_tags = Rails.error.handle(Redis::BaseError) { redis.get("tags") }

Can be restricted to handle only specific error classes:

end
1 + '1'
Rails.error.handle do
# Will report a TypeError to all subscribers and return nil.

specified.
returns the result of +fallback.call+, or +nil+ if +fallback+ is not
If no error is raised, returns the return value of the block. Otherwise,
Evaluates the given block, reporting and swallowing any unhandled error.
def handle(*error_classes, severity: :warning, context: {}, fallback: nil, source: DEFAULT_SOURCE)
  error_classes = [StandardError] if error_classes.blank?
  yield
rescue *error_classes => error
  report(error, handled: true, severity: severity, context: context, source: source)
  fallback.call if fallback
end