instance method
ensure_backtrace
Ruby on Rails 8.0.4
Since v8.0.4 PrivateAvailable in: v8.0.4 v8.1.2
Signature
ensure_backtrace(error)
No documentation comment.
Parameters
-
errorreq
Source
# File activesupport/lib/active_support/error_reporter.rb, line 252
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
Defined in activesupport/lib/active_support/error_reporter.rb line 252
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::ErrorReporter