Rake Task: error handling

点点圈 提交于 2019-12-10 01:34:54

问题


I am still learning Rake.

Does Rake has built in support to handle task's error like MSBuild of NANT: if this task failed; execute anoter tasks (rolling back, etc.)

e.g.: in MSBuild they have OnError element

<OnError ExecuteTargets="RollBackDatabase" />

Thanks for your help


回答1:


Found out the answer:

just use normal exception handling block

task :will_fail_task do
  begin
    raise "something's wrong here"
  rescue
    rollback()
    raise "error executing task"
  end
end


来源:https://stackoverflow.com/questions/4263401/rake-task-error-handling

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!