Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support IRB.conf[:BACKTRACE_FILTER] #917

Merged
merged 2 commits into from
May 1, 2024
Merged

Support IRB.conf[:BACKTRACE_FILTER] #917

merged 2 commits into from
May 1, 2024

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Apr 7, 2024

This config allows users to customize the backtrace of exceptions raised and displayed in IRB sessions. This is useful for filtering out library frames from the backtrace.

IRB expects the given value to response to filter method and return the filtered backtrace.

Closes #914

Notes

  • Ideally backtrace filters should be chainable, like Rack middlewares, to allow multiple sources to inject their own filters. However, I haven't seen much use cases for backtrace filtering outside of Rails', so I'm not sure if that'll actually be necessary.
  • To make IRB compatible with older Rails versions, we need to keep WorkSpace#filter_backtrace's behaviour the same at least for a few years.

@st0012 st0012 added the enhancement New feature or request label Apr 7, 2024
@st0012 st0012 self-assigned this Apr 7, 2024
@st0012 st0012 force-pushed the implement-#914 branch 3 times, most recently from b626a08 to e524a6f Compare April 7, 2024 13:32
lib/irb.rb Outdated Show resolved Hide resolved
Otherwise IRB would mis-recognize exceptions raised in test files as
exceptions raised in IRB itself.
This config allows users to customize the backtrace of exceptions raised
and displayed in IRB sessions. This is useful for filtering out library
frames from the backtrace.

IRB expects the given value to response to `call` method and return
the filtered backtrace.
@tompng tompng merged commit 6f6e87d into master May 1, 2024
59 checks passed
@tompng tompng deleted the implement-#914 branch May 1, 2024 14:23
matzbot pushed a commit to ruby/ruby that referenced this pull request May 1, 2024
(ruby/irb#917)

* Use 'irbtest-' instead if 'irb-' as prefix of test files.

Otherwise IRB would mis-recognize exceptions raised in test files as
exceptions raised in IRB itself.

* Support `IRB.conf[:BACKTRACE_FILTER]``

This config allows users to customize the backtrace of exceptions raised
and displayed in IRB sessions. This is useful for filtering out library
frames from the backtrace.

IRB expects the given value to response to `call` method and return
the filtered backtrace.

ruby/irb@6f6e87d769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

Introduce IRB.conf[:backtrace_filter] for upstream projects to extend filter_backtrace
2 participants