instance method handle

Ruby on Rails 7.0.10

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

handle(error_class = StandardError, severity: :warning, context: {}, fallback: nil)

Report any unhandled exception, and swallow it.

Rails.error.handle do
  1 + '1'
end

Parameters

error_class opt = StandardError
severity key = :warning
context key = {}
fallback key = nil
Source
# File activesupport/lib/active_support/error_reporter.rb, line 57
    def handle(error_class = StandardError, severity: :warning, context: {}, fallback: nil)
      yield
    rescue error_class => error
      report(error, handled: true, severity: severity, context: context)
      fallback.call if fallback
    end

Defined in activesupport/lib/active_support/error_reporter.rb line 57 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::ErrorReporter

Type at least 2 characters to search.

↑↓ navigate · open · esc close