开发者

Can I dynamically place a breakpoint in the event of an exception in Ruby?

开发者 https://www.devze.com 2023-01-30 15:07 出处:网络
I\'d like to be able to set conditional breakpoints in ruby-debug, where the condition is \"An exception was thrown.\"

I'd like to be able to set conditional breakpoints in ruby-debug, where the condition is "An exception was thrown."

What I'd like is the ability to land on a breakpoint whenever an exception is thrown on that line (a la MATLAB's ultra-convenient dbstop if error option i开发者_如何学编程llustrated here).

Thanks in advance.


the example you provided "debugger if XXXXX" should work fine.

if the statement debugger works for you, there is no reason

if some_condition
debugger
end

would not, and that is basically what your line does. I do this all the time and it works fine.

for breaking on exceptions, you can override the class Exception and put the debugger statement in the initializer method.

0

精彩评论

暂无评论...
验证码 换一张
取 消