# HG changeset patch # User John W. Eaton # Date 1203122954 18000 # Node ID 1e01db14700bb1d3a53592dc5daaf7fd14b20eda # Parent 6a6d2abe51ff78913838c0bb54a8468ebd9b3a58 catch octave_execution_exception for built-in and mex functions diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2008-02-15 John W. Eaton + + * ov-builtin.cc (octave_builtin::do_multi_index_op): + Catch possible octave_execution_exception. + * ov-mex-fcn.cc (octave_mex_function::do_multi_index_op): Likewise. + * ov.cc (do_binary_op, do_cat_op, do_unary_op, + octave_value::do_non_const_unary_op): Likewise. + 2008-02-14 John W. Eaton * DLD-FUNCTIONS/balance.cc, DLD-FUNCTIONS/qz.cc: diff --git a/src/ov-builtin.cc b/src/ov-builtin.cc --- a/src/ov-builtin.cc +++ b/src/ov-builtin.cc @@ -101,7 +101,15 @@ unwind_protect::add (octave_call_stack::unwind_pop, 0); - retval = (*f) (args, nargout); + try + { + retval = (*f) (args, nargout); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } unwind_protect::run_frame ("builtin_func_eval"); } diff --git a/src/ov-mex-fcn.cc b/src/ov-mex-fcn.cc --- a/src/ov-mex-fcn.cc +++ b/src/ov-mex-fcn.cc @@ -143,7 +143,15 @@ unwind_protect::add (octave_call_stack::unwind_pop, 0); - retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); + try + { + retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } unwind_protect::run_frame ("mex_func_eval"); } diff --git a/src/ov.cc b/src/ov.cc --- a/src/ov.cc +++ b/src/ov.cc @@ -1526,7 +1526,17 @@ = octave_value_typeinfo::lookup_binary_class_op (op); if (f) - retval = f (v1, v2); + { + try + { + retval = f (v1, v2); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else gripe_binary_op (octave_value::binary_op_as_string (op), v1.class_name (), v2.class_name ()); @@ -1540,7 +1550,17 @@ = octave_value_typeinfo::lookup_binary_op (op, t1, t2); if (f) - retval = f (*v1.rep, *v2.rep); + { + try + { + retval = f (*v1.rep, *v2.rep); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else { octave_value tv1; @@ -1590,7 +1610,17 @@ f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); if (f) - retval = f (*tv1.rep, *tv2.rep); + { + try + { + retval = f (*tv1.rep, *tv2.rep); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else gripe_binary_op (octave_value::binary_op_as_string (op), v1.type_name (), v2.type_name ()); @@ -1637,7 +1667,17 @@ = octave_value_typeinfo::lookup_cat_op (t1, t2); if (f) - retval = f (*v1.rep, *v2.rep, ra_idx); + { + try + { + retval = f (*v1.rep, *v2.rep, ra_idx); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else { octave_value tv1; @@ -1687,7 +1727,17 @@ f = octave_value_typeinfo::lookup_cat_op (t1, t2); if (f) - retval = f (*tv1.rep, *tv2.rep, ra_idx); + { + try + { + retval = f (*tv1.rep, *tv2.rep, ra_idx); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else gripe_cat_op (v1.type_name (), v2.type_name ()); } @@ -1734,7 +1784,17 @@ = octave_value_typeinfo::lookup_unary_class_op (op); if (f) - retval = f (v); + { + try + { + retval = f (v); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else gripe_unary_op (octave_value::unary_op_as_string (op), v.class_name ()); @@ -1748,7 +1808,17 @@ = octave_value_typeinfo::lookup_unary_op (op, t); if (f) - retval = f (*v.rep); + { + try + { + retval = f (*v.rep); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else { octave_value tv; @@ -1767,7 +1837,17 @@ f = octave_value_typeinfo::lookup_unary_op (op, t); if (f) - retval = f (*tv.rep); + { + try + { + retval = f (*tv.rep); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } + } else gripe_unary_op (octave_value::unary_op_as_string (op), v.type_name ()); @@ -1806,7 +1886,15 @@ { make_unique (); - f (*rep); + try + { + f (*rep); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } } else { @@ -1827,7 +1915,15 @@ if (f) { - f (*rep); + try + { + f (*rep); + } + catch (octave_execution_exception) + { + octave_exception_state = octave_no_exception; + error ("caught execution error in library function"); + } if (old_rep && --old_rep->count == 0) delete old_rep;