method

ensure_backtrace

ensure_backtrace(error)
private

No documentation available.

# 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