有没有办法启动Ruby调试器的异常? [英] Is there any way to start the Ruby debugger on exception?

查看:101
本文介绍了有没有办法启动Ruby调试器的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <$ c 

有没有办法启动/一个Ruby调试器,无论何时代码抛出异常$ c> begin
#do something
rescue
debugger
end

我想要这样做,如果做某事部分引发异常,调试器将开始。这是很好的不必修改代码添加开始救援块全部。

解决方案

我偶然遇到这个页面:一个href =http://bashdb.sourceforge.net/ruby-debug.html#SEC70 =nofollow noreferrer>验尸调试。这样做:

  Debugger.start(:post_mortem => true)
/ pre>

得到我想要的地方。


Is there any way to start the/a Ruby debugger whenever the code throws an exception, without me wrapping the code like this:

begin
  #do something
rescue
  debugger
end

I'd like to have it in such a way that if the do something part raises an exception, the debugger will start. It would be nice not having to modify the code to add begin rescue blocks all over.

解决方案

I stumbled across this page:post-mortem debugging. Doing this:

Debugger.start(:post_mortem => true)

gets me where I want to.

这篇关于有没有办法启动Ruby调试器的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆