-
Notifications
You must be signed in to change notification settings - Fork 340
Shush the backtrace_locations
, too
#740
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
base: main
Are you sure you want to change the base?
Shush the backtrace_locations
, too
#740
Conversation
if $! | ||
lib = File.expand_path("..", __FILE__) | ||
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen? | ||
unless $!.backtrace.frozen? | ||
$!.backtrace.reject! { |line| line.start_with?(lib) } | ||
$!.backtrace_locations.reject! { |line| line.path.start_with?(lib) } | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we feel about giving $!
a more reasonable name?
if $! | |
lib = File.expand_path("..", __FILE__) | |
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen? | |
unless $!.backtrace.frozen? | |
$!.backtrace.reject! { |line| line.start_with?(lib) } | |
$!.backtrace_locations.reject! { |line| line.path.start_with?(lib) } | |
end | |
end | |
error = $! | |
if error | |
lib = File.expand_path("..", __FILE__) | |
unless error.backtrace.frozen? | |
error.backtrace.reject! { |line| line.start_with?(lib) } | |
error.backtrace_locations.reject! { |line| line.path.start_with?(lib) } | |
end | |
end |
@@ -319,7 +319,10 @@ def shush_backtraces | |||
ensure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found this confusing. Is there any reason to use ensure
+ $!
, rather than just rescue => e
+ raise e
?
I thought perhaps because a re-raise would introduce a new frame into the backtrace, but it doesn't
demo
#!/opt/rubies/3.4.2/bin/ruby
begin
raise
rescue => e
raise e
end
# Prints:
# demo.rb:4:in '<main>': unhandled exception
# As you see, line 5 and 6 aren't in the backtrace.
5bc96f5
to
774c1d5
Compare
Fixes #739
Didn't change any tests, because I couldn't find any tests that covered this behaviour.