2012-05-24 64 views
0

时,我有这样的任务...任务没有得到“失败”使用救援

def self.perform(parsed_json) 
do_hard_work 
use_faye_to_push_status 
rescue => exception 
    use_faye_to_push_error 
end 

,但是,当我用“拯救”,该任务不会失败的任务列表上输入。有没有办法,即使使用rescue,将任务设置为失败?

回答

4

从错误中拯救将继续进一步调用堆栈停止。随着中说,你可以简单地rescue块内再次raise以向上传播它:

def self.perform(parsed_json) 
    do_hard_work 
    use_faye_to_push_status 
rescue => exception 
    use_faye_to_push_error 
    raise 
end 
+0

编辑:NVM,我会看看 –