From a13eb2a5837aab00cf97fc253fda5de0819d3424 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 19 Dec 2011 09:54:11 +0100 Subject: [PATCH] error handling in queue framework --- matlab/Add2Queue.m | 5 ++++- matlab/CheckQueue.m | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/matlab/Add2Queue.m b/matlab/Add2Queue.m index f9de813..a80bdc9 100644 --- a/matlab/Add2Queue.m +++ b/matlab/Add2Queue.m @@ -38,8 +38,11 @@ queue.jobs{jobnum}.outargsfile = [tempname '.mat']; queue.jobs{jobnum}.command = [queue.bin queue.bin_options ' "load(''' queue.jobs{jobnum}.argsfile ''');' ... queue.DependPath ... + 'err=[];' ... + 'try;' ... '[outargs{1:' num2str(queue.jobs{jobnum}.nargout) '}]=' func_name '(func_args{:});' ... - 'save(''-V7'',''' queue.jobs{jobnum}.outargsfile ''',''outargs'');' ... + 'catch err;outargs=0;end;' ... + 'save(''-V7'',''' queue.jobs{jobnum}.outargsfile ''',''outargs'',''err'');' ... 'exit;"']; [queue.jobs{jobnum}.pid, queue.jobs{jobnum}.filenames] = queue_addProcess( queue.jobs{jobnum}.command ); diff --git a/matlab/CheckQueue.m b/matlab/CheckQueue.m index bd9747c..748d706 100644 --- a/matlab/CheckQueue.m +++ b/matlab/CheckQueue.m @@ -33,6 +33,10 @@ for n=1:numJobs if (queue_checkProcess( queue.jobs{n}.pid, queue.jobs{n}.filenames)==0) queue.jobs_finished(n)=1; load(queue.jobs{n}.outargsfile); + if ~isempty(err) + disp(['Job with number ' num2str(n) ' failed to execute: Error message:']); + error(['CheckQueue:' err.message]); + end queue.jobs{n}.outargs = outargs; % read in output and cleanup