instance method ensure_backtrace

Ruby on Rails 8.1.2

Since v8.0.4 Private

Available in: v8.0.4 v8.1.2

Signature

ensure_backtrace(error)

No documentation comment.

Parameters

error req
Source
# File activesupport/lib/active_support/error_reporter.rb, line 278
      def ensure_backtrace(error)
        return if error.frozen? # re-raising won't add a backtrace or set the cause
        return unless error.backtrace.nil?

        begin
          # As of Ruby 3.4, we could use Exception#set_backtrace to set the backtrace,
          # but there's nothing like Exception#set_cause. Raising+rescuing is the only way to set the cause.
          raise error
        rescue error.class => error
        end

        count = 0
        while error.backtrace_locations.first&.path == __FILE__
          count += 1
          error.backtrace_locations.shift
        end

        error.backtrace.shift(count)
      end

Defined in activesupport/lib/active_support/error_reporter.rb line 278 · 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