【发布时间】:2016-03-21 23:19:58
【问题描述】:
假设我有以下内容:
begin
raise 'Exception!'
rescue => e
puts "Rescued exception: #{e.message}"
raise 'Something I did in this block raised an exception!'
end
Rubyist 捕获第二个异常的方法是什么?最好将整个东西包装在另一个开始救援块中,还是有更优雅的解决方案?
【问题讨论】:
-
如果你在 Rails 中,还有
rescue_from。