-
Notifications
You must be signed in to change notification settings - Fork 49
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
Pry-Rescue stops on enter_exception_context
instead of the actual error
#124
Comments
enter_exception_context
instead of the actual error
I confirm that we are experiencing exactly the same issue on our side since few weeks...
|
I want to confirm that the error is still present and it occurs when pry-byebug 3.10.1 is used together with pry-rescue. Working example: require 'pry-rescue'
def test
raise "foo"
rescue => e
raise "bar"
end
Pry.rescue do
test
end Work as expected: Frame number: 0/6
Frame type: rescue
From: /home/user/testrescue.rb:6 Object#test:
3: def test
4: raise "foo"
5: rescue => e
=> 6: raise "bar"
7: end
RuntimeError: bar
from testrescue.rb:6:in `rescue in test'
Caused by RuntimeError: foo
from testrescue.rb:4:in `test' Bad example: require 'pry-rescue'
require "pry-byebug"
def test
raise "foo"
rescue => e
raise "bar"
end
Pry.rescue do
test
end It does not work as expected: Frame number: 0/23
From: /usr/share/rvm/gems/ruby-3.2.2/gems/pry-rescue-1.5.2/lib/pry-rescue.rb:65 PryRescue.enter_exception_context:
46: def enter_exception_context(exception)
47: @any_exception_captured = true
48: @exception_context_depth ||= 0
49: @exception_context_depth += 1
50:
51: exception = exception.instance_variable_get(:@rescue_cause) if phantom_load_raise?(exception)
52: bindings = exception.instance_variable_get(:@rescue_bindings)
53:
54: bindings = without_bindings_below_raise(bindings)
55: bindings = without_duplicates(bindings)
56:
57: with_program_name "#$PROGRAM_NAME [in pry-rescue @ #{Dir.pwd}]" do
58: if defined?(PryStackExplorer)
59: pry :call_stack => bindings,
60: :hooks => pry_hooks(exception),
61: :initial_frame => initial_frame(bindings)
62: else
63: Pry.start bindings.first, :hooks => pry_hooks(exception)
64: end
=> 65: end
66: ensure
67: @exception_context_depth -= 1
68: end
This is quite an issue because both the libraries (pry-rescue and pry-byebug) are important, and downgrade is not possible since the old version of bye-prybug does not support Ruby 3.2. |
See ConradIrwin/pry-rescue#124 --- pry-byebug doesn't play nicely with pry-rescue. Detect if we're in a rescued exception, and if so, use pry without byebug.
See deivid-rodriguez/pry-byebug#422 --- this disables byebug when pry is invoked by pry-rescue. Gemfile: gem 'pry-byebug', github: 'cygnuseducation/pry-byebug' |
@afn jesus, thanks! Finally |
We have upgraded our stack recently and are now on rails 7.0.0 and ruby 3.1.1.
Since then when I run :
PRY_RESCUE_RAILS=1 bundle exec rails test test/controllers/...
(or every other ways of launching my test with pry-rescue) the context is stopped in theenter_exception_context
rather than on the error itself:Any idea how to fix this ?
The text was updated successfully, but these errors were encountered: