changeset 16000:3f93cd251bdb

fix ErrorHandler in cellfun (bug #38256) * cellfun.cc: The ErrorHandler was not executed on some errors that throw an expection. Test added.
author Stefan Mahr <dac922@gmx.de>
date Tue, 05 Feb 2013 16:57:51 +0100
parents 9e710110401c
children 7275cfaddb5e 369b173d6c16
files libinterp/corefcn/cellfun.cc
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/cellfun.cc	Tue Feb 05 15:42:52 2013 +0100
+++ b/libinterp/corefcn/cellfun.cc	Tue Feb 05 16:57:51 2013 +0100
@@ -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)
     {
@@ -996,6 +1003,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")});