def run_task
      begin
        run 
      rescue Exception => e
        @task_run.add_error_text(e.class.name + ": " + e.message)
        @task_run.add_error_text(e.backtrace.inspect)
        @task_run.success = false
      end 

      finally

      @task_run.end_time = Time.now
      @task_run.save
    end
def run_task
      begin
        run 
      rescue Exception => e
        @task_run.add_error_text(e.class.name + ": " + e.message)
        @task_run.add_error_text(e.backtrace.inspect)
        @task_run.success = false
      end 

      finally

      @task_run.end_time = Time.now
      @task_run.save
    end
this calls task with error catching
 if an error is caught, sets success to false and records the error
 either way, sets an end time and saves the task run information

 After the run completes, whether or not the run succeeds, run finally
 If finally has an error, don't catch it