ruby / irb

interactive Ruby
BSD 2-Clause "Simplified" License
393 stars 119 forks source link

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

Closed joshbroughton closed 7 months ago

joshbroughton commented 8 months ago

Description

If upstream projects (like Rails) want to extend or alter the behaviour of filter_backtrace, they currently have to override the filter_backtrace method (like Rails does here). Directly overriding a method of the internal WorkSpace component is not a great way to extend a behaviour. Instead, we could add a config that creates a more proper way for upstream projects to extend the filter.

A better way to do this would be to:

Introduce IRB.conf[:backtrace_filter] that’s invoked after filter_backtrace is called. Ideally, IRB.conf[:backtrace_filter] = Rails.backtrace_cleaner should fully replace the current handle_exception patch. But we’ll see if that’s possible when we have a PR The above means that IRB’d expect the value of backtrace_filter to implement a filter(array_of_backtrace) method

Thanks for the suggestion on how to approach this @st0012