diff options
Diffstat (limited to 'lib/Task.cc')
-rw-r--r-- | lib/Task.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Task.cc b/lib/Task.cc index 79c39e1..27d2a24 100644 --- a/lib/Task.cc +++ b/lib/Task.cc @@ -1,6 +1,8 @@ +#include <iostream.h> #include "Task.h" +#include "String.h" -Task::Task() {} +Task::Task() : state(TASK_ON_HOLD) {} Task::~Task() {} int Task::Do() { @@ -8,9 +10,22 @@ int Task::Do() { } int Task::Run() { - return (state = Do()); + cerr << "Running task '" << GetName() << "'...\n"; + try { + while ((state = Do()) != TASK_DONE); + } + catch (GeneralException e) { + cerr << "Task " << GetName() << " caused an unexpected exception: '" << e.GetMsg() << "', closing it.\n"; + return TASK_DONE; + } + + return state; } int Task::GetState() { return state; } + +String Task::GetName() { + return "Unknow Task"; +} |