method

ensure_backtrace

ensure_backtrace(error)
private

No documentation available.

# File activesupport/lib/active_support/error_reporter.rb, line 243
      def ensure_backtrace(error)
        return if error.frozen? # re-raising won't add a backtrace
        return unless error.backtrace.nil?

        begin
          # We could use Exception#set_backtrace, but until Ruby 3.4
          # it only support setting `Exception#backtrace` and not
          # `Exception#backtrace_locations`. So raising the exception
          # is a good way to build a real backtrace.
          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