开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜