Skip to content

Add annotation to backtraces for practicality. - #3151

Merged
ksss merged 1 commit into
ruby:masterfrom
ksss:error-backtrace
Sep 23, 2026
Merged

ksss merged 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.

@ksss
ksss added this pull request to the merge queue Sep 23, 2026
Merged via the queue into ruby:master with commit 6ed6cc7 Sep 23, 2026
24 checks passed
@ksss
ksss deleted the error-backtrace branch September 23, 2026 10:44
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