From d975109e1ff6a7d7a77a078f4d9271eccc45ef32 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Thu, 10 Jul 2008 20:21:43 +0000 Subject: [PATCH] added that friendly error message to www_runCronJob --- lib/WebGUI/Operation/Cron.pm | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Operation/Cron.pm b/lib/WebGUI/Operation/Cron.pm index 08a7af606..38ff395e0 100644 --- a/lib/WebGUI/Operation/Cron.pm +++ b/lib/WebGUI/Operation/Cron.pm @@ -277,16 +277,30 @@ sub www_runCronJob { } my $taskId = $session->form->param("taskId"); if ($taskId) { - my $task = WebGUI::Workflow::Cron->new($session, $taskId); + # Try to instantiate the task + my $task = WebGUI::Workflow::Cron->new($session, $taskId); return "done" unless (defined $task); - WebGUI::Workflow::Instance->create($session, { - workflowId=>$task->get("workflowId"), - className=>$task->get("className"), - methodName=>$task->get("methodName"), - parameters=>$task->get("parameters"), - priority=>$task->get("priority"), - })->start(1); - $task->delete(1) if ($task->get("runOnce")); + + # Make a new workflow instance + my $instance = + WebGUI::Workflow::Instance->create($session, { + workflowId => $task->get("workflowId"), + className => $task->get("className"), + methodName => $task->get("methodName"), + parameters => $task->get("parameters"), + priority => $task->get("priority"), + }); + if ( !$instance ) { + $session->errorHandler->error( + "Could not create workflow instance for workflowId '" . $task->get( "workflowId" ) + . "': The result was undefined" + ); + return "done"; + } + + # Run the instance + $instance->start( 1 ); + $task->delete( 1 ) if ( $task->get("runOnce") ); return "done"; } $session->errorHandler->warn("No task ID passed to cron job runner.");