Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support of task failures #1

Open
AlenPelin opened this issue Jun 14, 2015 · 4 comments
Open

Add support of task failures #1

AlenPelin opened this issue Jun 14, 2015 · 4 comments

Comments

@AlenPelin
Copy link
Collaborator

Currently, if one of the tasks fails with unhandled exception, the entire system fails with this exception. We need to make the system more stable by adding failure control functionality.

@gravypower
Copy link
Owner

Yeah, maybe give the ability to defyn a delegate to handle a failed task?

@AlenPelin
Copy link
Collaborator Author

I think that the task should handle all exceptions it can handle, all the rest must notify the user so that the user can take action and re-run one or all the failed tests. The task runner should do this thing:

try 
{ 
   task.Action.Invoke();
   return new TaskResult(TaskResultType.Passed);
} 
catch (ThreadAbortException)
{
  return new TaskResult(TaskResultType.Aborted);
}
catch (Exception ex)
{
   return new TaskResult(TaskResultType.Failed, ex);
}

and it should have API like:

var tc = new TaskContainer();
...
tc.OnTaskFault += (task, ex) => Console.WriteLine("The {0} task failed. {1}", task.Name, ex.Message);
var result = tc.Run();
while (result.HasErrors)
{
  var failedTasks = result.FailedTasks; // failed tasks and the exceptions
  var reRunMode = AskUserAboutReRunMode(failedTasks);
  if(ReRunMode.All == reRunMode)
  {
    result = tc.ReRun();
  }
  else if(ReRunMode.SelectedTasks == reRunMode)
  {
    var tasksToReRun = AskUserWhichTasksToReRun(failedTasks);
    result = tc.ReRun(tasksToReRun);
  }
}

@gravypower
Copy link
Owner

I dont think we should handle the exception as this should be the responsibility of the class using the API.

Have done some playing with the code, see the new SimpleTasks.Play project for an idea of what I am thinking of.

I will implement the suggestions you have suggested also at some point so we can weigh up the options between the two.

@gravypower gravypower added this to the Version 1.0 milestone Jun 17, 2015
@gravypower
Copy link
Owner

Need to have the ability to know what tasks completed and what tasks could not run. The tasks that could not run should also include dependants of these tasks as they also should not have executed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants