Commit deab7d7f authored by Brad Kennedy's avatar Brad Kennedy
Browse files

Octave exit wrapper now contains ef_print_error

parent 60cac31f
% exit_wrapper() - function that wraps any script providing exit statuses
%
% Usage:
% >> octave exit_wrapper script-name
%
% Inputs:
% script-name - the script to watchdog
% Copyright (C) 2017 Brock University Cognitive and Affective Neuroscience Lab
%
% Code written by Brad Kennedy
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program (LICENSE.txt file in the root directory); if not,
% write to the Free Software Foundation, Inc., 59 Temple Place,
% Suite 330, Boston, MA 02111-1307 USA
function ef_print_error(err)
try
builtin('disp', ['Error: ' err.message]);
output = '';
stack = err.stack;
for i = 1:numel(stack)
level = stack(i);
output = [output sprintf('\tat %s(%s:%d)\n', level.file, ...
level.name, level.line)];
end
builtin('disp', ['Stack trace:', char(10), output]);
catch err
builtin('disp', ['Stack trace not available, error was' err.message]);
end
end
......@@ -54,6 +54,19 @@ try
eval(['fhandle = @', name, ';']);
feval(fhandle, arg_list{:});
catch err
ef_print_error(err);
exit(1);
try
builtin('disp', ['Error: ' err.message]);
output = '';
stack = err.stack;
for i = 1:numel(stack)
level = stack(i);
output = [output sprintf('\tat %s(%s:%d)\n', level.file, ...
level.name, level.line)];
end
builtin('disp', ['Stack trace:', char(10), output]);
catch err
builtin('disp', ['Stack trace not available, error was' err.message]);
end
exit(1);
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment