Skip to content

Add annotation to backtraces for practicality. - #3151

Open
ksss wants to merge 1 commit into
ruby:masterfrom
ksss:error-backtrace
Open

ksss wants to merge 1 commit into
ruby:masterfrom
ksss:error-backtrace

Conversation

@ksss

@ksss ksss commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Exception#backtrace may return nil.

Exception.new.backtrace #=> nil

However, in practical use cases, backtraces are almost never nil in the vast majority of situations.

begin
  ...
rescue => e
  logger.warn(e.backtrace.join("\n"))

  loc = ex.backtrace_location.first
  loc.lineno
end

Similar to other overloads marked with %a{implicitly-returns-nil}, I propose adding %a{implicitly-returns-nil} to backtraces as well, placing emphasis on practicality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant