2014-10-18 28 views
0

模板方法的優雅不顯眼的方式如下所示?這個想法是「動態地」在方法內部的錯誤上插入binding.pry來簡化調試。Ruby Pry調試

def foo #regular method 
... 
end 

def foo #method changed to debug errors 
begin 
    ... 
rescue 
    binding.pry 
end 
end 
+1

嘗試['pry-rescue'](https://github.com/ConradIrwin/pry-rescue) – 2014-10-18 09:01:53

+0

完全按照我想要的方式工作。謝謝! – 2014-10-18 09:19:39

回答

2

您可以使用pry-rescue

pry-rescueRuby的 「對未處理的異常中斷」 的實現。每當發生異常但未獲救時,撬手 將自動爲您打開Pry。