Skip to content

Support IRB.conf[:BACKTRACE_FILTER] - #917

Merged
tompng merged 2 commits into
masterfrom
implement-#914
May 1, 2024
Merged

tompng merged 2 commits into
masterfrom
implement-#914

Conversation

@st0012

@st0012 st0012 commented Apr 7, 2024 •

Copy link
Copy Markdown
Member

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
Comment thread lib/irb.rb Resolved
st0012 added 2 commits April 30, 2024 18:38
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.
@st0012
st0012 requested a review from tompng April 30, 2024 20:26
@tompng
tompng merged commit 6f6e87d into master May 1, 2024
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants