# HG changeset patch # User David Bateman # Date 1217235046 -7200 # Node ID 065c28e1c3687d02425f1cbe39e32d32d9d9e33a # Parent 736124a4fa3d2fdaf9c97dd5be26c6ab35f8b349 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2008-07-28 David Bateman + + * error.cc (last_error_id, last_error_message, last_warning_id, + last_warning_message): New functions to return the error/warning + message and id without exposing the internal values. + * error.h (last_error_id, last_error_message, last_warning_id, + last_warning_message): Declare them. + * DLD-FUNCTIONS/cellfun.cc (Fcellfun): Use them to pass the error + to the ErrorHandler function. + 2008-07-28 John W. Eaton * error.cc (Flasterror, Flasterr): Unwind-protect error_state. 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 @@ -38,9 +38,6 @@ #include "ov-colon.h" #include "unwind-prot.h" -extern octave_value_list -Flasterr (const octave_value_list& args_name, int nargout_name); - DEFUN_DLD (cellfun, args, nargout, " -*- texinfo -*-\n\ @deftypefn {Loadable Function} {} cellfun (@var{name}, @var{c})\n\ @@ -364,13 +361,10 @@ if (error_state && have_error_handler) { - octave_value_list errtmp = - Flasterr (octave_value_list (), 2); - Octave_map msg; - msg.assign ("identifier", errtmp(1)); - msg.assign ("message", errtmp(0)); - msg.assign ("index", octave_value(double (count))); + msg.assign ("identifier", last_error_id ()); + msg.assign ("message", last_error_message ()); + msg.assign ("index", octave_value(double (count + static_cast(1)))); octave_value_list errlist = inputlist; errlist.prepend (msg); buffer_error_messages--; @@ -443,13 +437,10 @@ if (error_state && have_error_handler) { - octave_value_list errtmp = - Flasterr (octave_value_list (), 2); - Octave_map msg; - msg.assign ("identifier", errtmp(1)); - msg.assign ("message", errtmp(0)); - msg.assign ("index", octave_value(double (count))); + msg.assign ("identifier", last_error_id ()); + msg.assign ("message", last_error_message ()); + msg.assign ("index", octave_value(double (count + static_cast(1)))); octave_value_list errlist = inputlist; errlist.prepend (msg); buffer_error_messages--; diff --git a/src/error.cc b/src/error.cc --- a/src/error.cc +++ b/src/error.cc @@ -1740,6 +1740,30 @@ return SET_INTERNAL_VARIABLE (debug_on_warning); } +std::string +last_error_message (void) +{ + return Vlast_error_message; +} + +std::string +last_error_id (void) +{ + return Vlast_error_id; +} + +std::string +last_warning_message (void) +{ + return Vlast_warning_message; +} + +std::string +last_warning_id (void) +{ + return Vlast_warning_id; +} + /* ;;; Local Variables: *** ;;; mode: C++ *** diff --git a/src/error.h b/src/error.h --- a/src/error.h +++ b/src/error.h @@ -114,6 +114,12 @@ // TRUE means warning messages are turned off. extern OCTINTERP_API bool discard_warning_messages; +// Helper functions to pass last error and warning messages and ids +extern OCTINTERP_API std::string last_error_message (void); +extern OCTINTERP_API std::string last_error_id (void); +extern OCTINTERP_API std::string last_warning_message (void); +extern OCTINTERP_API std::string last_warning_id (void); + #endif /*