# HG changeset patch # User jwe # Date 1196794966 0 # Node ID d35fa45980c60718fefb310af08354448a633b2e # Parent ace1030cbe367d5c0de4c1182c5b80d3232c546d [project @ 2007-12-04 19:02:46 by jwe] diff -r ace1030cbe36 -r d35fa45980c6 src/ChangeLog --- a/src/ChangeLog Tue Dec 04 18:18:47 2007 +0000 +++ b/src/ChangeLog Tue Dec 04 19:02:46 2007 +0000 @@ -1,5 +1,7 @@ 2007-12-04 John W. Eaton + * error.cc (Ferror): Handle error id. + * load-save.cc (Fsave, Fload): Doc fixes. From Marco Caliari . diff -r ace1030cbe36 -r d35fa45980c6 src/error.cc --- a/src/error.cc Tue Dec 04 18:18:47 2007 +0000 +++ b/src/error.cc Tue Dec 04 19:02:46 2007 +0000 @@ -963,6 +963,7 @@ DEFUN (error, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\ +@deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\ Format the optional arguments under the control of the template string\n\ @var{template} using the same rules as the @code{printf} family of\n\ functions (@pxref{Formatted Output}) and print the resulting message\n\ @@ -1016,18 +1017,43 @@ @end example\n\ @end deftypefn") { - // FIXME -- need to extract and pass message id to - // handle_message. + octave_value retval; + + int nargin = args.length (); + + octave_value_list nargs = args; + + std::string id; + + if (nargin > 1) + { + std::string arg1 = args(0).string_value (); - octave_value_list retval; - handle_message (error_with_id, "", "unspecified error", args); + if (! error_state) + { + if (arg1.find ('%') == NPOS) + { + id = arg1; + + nargs.resize (nargin-1); + + for (int i = 1; i < nargin; i++) + nargs(i-1) = args(i); + } + } + else + return retval; + } + + handle_message (error_with_id, id.c_str (), "unspecified error", nargs); + return retval; } DEFCMD (warning, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ -@deftypefnx {Built-in Function} {} warning (@var{id}, @var{template})\n\ +@deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\ Format the optional arguments under the control of the template string\n\ @var{template} using the same rules as the @code{printf} family of\n\ functions (@pxref{Formatted Output}) and print the resulting message\n\ @@ -1343,8 +1369,6 @@ return retval; } - // handle_message. - std::string prev_msg = Vlast_warning_message; std::string curr_msg = handle_message (warning_with_id, id.c_str (),