# HG changeset patch # User Stefan Mahr # Date 1360607204 18000 # Node ID 1678d0fca14607bad8117587df9a33321a0055ff # Parent 8cf7db67c1a26ac53e4ef652443dd6e43dc5d573 fix ErrorHandler in cellfun (bug #38256) * cellfun.cc: The ErrorHandler was not executed on some errors that throw an expection. Test added. diff --git a/src/DLD-FUNCTIONS/cellfun.cc b/src/DLD-FUNCTIONS/cellfun.cc --- a/src/DLD-FUNCTIONS/cellfun.cc +++ b/src/DLD-FUNCTIONS/cellfun.cc @@ -69,7 +69,14 @@ octave_value& func, octave_value& error_handler) { - octave_value_list tmp = func.do_multi_index_op (nargout, inputlist); + octave_value_list tmp; + try { + tmp = func.do_multi_index_op (nargout, inputlist); + } + catch (octave_execution_exception) { + if (error_handler.is_defined ()) + error_state = 1; + } if (error_state) { @@ -1001,6 +1008,7 @@ %!assert(cellfun(@atan2,{1,1;1,1},{1,2;1,2}),atan2([1,1;1,1],[1,2;1,2])) %!error(cellfun(@factorial,{-1,3})) %!assert(cellfun(@factorial,{-1,3},'ErrorHandler',@(x,y) NaN),[NaN,6]) +%!assert (cellfun (@(x) x(2),{[1],[1,2]},"ErrorHandler",@(x,y) NaN), [NaN,2]) %!test %! [a,b,c]=cellfun(@fileparts,{fullfile("a","b","c.d"),fullfile("e","f","g.h")},'UniformOutput',false); %! assert(a,{fullfile("a","b"),fullfile("e","f")})