summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-07-06 07:39:36 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-07-06 07:39:36 -0700
commitf381927ec6bca75e9c588725318f6682bf74d103 (patch)
tree11dd31d6ffc6aa90ac608da75b85545369abdc5b
parent04f02b49c5d524345bc916aad6e247c714177662 (diff)
Catch exceptions that are thrown within the task and log them to the task log
and then set the task to done, the state to error and the status message set to the Exception Message.
-rw-r--r--modules/gallery/helpers/task.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 79a7c93b..06568887 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -76,9 +76,17 @@ class task_Core {
throw new Exception("@todo MISSING_TASK");
}
- $task->state = "running";
- call_user_func_array($task->callback, array(&$task));
- $task->save();
+ try {
+ $task->state = "running";
+ call_user_func_array($task->callback, array(&$task));
+ $task->save();
+ } catch (Exception $e) {
+ $task->log($e->__toString());
+ $task->state = "error";
+ $task->done = true;
+ $task->status = $e->getMessage();
+ $task->save();
+ }
return $task;
}