最佳答案
当我获得异常时,它通常来自调用堆栈的深处。当这种情况发生时,通常情况下,真正令人讨厌的代码行对我来说是隐藏的:
tmp.rb:7:in `t': undefined method `bar' for nil:NilClass (NoMethodError)
from tmp.rb:10:in `s'
from tmp.rb:13:in `r'
from tmp.rb:16:in `q'
from tmp.rb:19:in `p'
from tmp.rb:22:in `o'
from tmp.rb:25:in `n'
from tmp.rb:28:in `m'
from tmp.rb:31:in `l'
... 8 levels...
from tmp.rb:58:in `c'
from tmp.rb:61:in `b'
from tmp.rb:64:in `a'
from tmp.rb:67
“…8级……”截断给我带来了很多麻烦。我在谷歌上搜索这个问题时没有取得多大的成功:我如何告诉ruby我想要转储包含完整的堆栈?