Reputation: 1819
I'm using ruby-debug to dive into code that's throwing and silently eating exceptions. (The code is inside a gem, so I'm loathe to edit it directly without a really good reason.)
I get to this line:
167 def catch_exceptions
168 begin
169 yield
170 rescue Exception
=> 171 rollback
172 end
173 end
174
As line 170 isn't defined as rescue Exception => e
, there's no exception object declared.
Is there a way of inspecting this "implicit" exception object?
Upvotes: 0
Views: 121
Reputation: 16012
You can access the most recent exception using the global variable $!
.
I know you don't always have a choice but consider fixing the gem or using a different one. That catch-all approach is really bad when it comes to tracing down exceptions.
Upvotes: 3