Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake Task: error handling

Tags:

ruby

rake

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

like image 393
kite Avatar asked Nov 24 '10 04:11

kite


1 Answers

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
like image 170
kite Avatar answered Oct 21 '22 12:10

kite