Mercurial > hg > octave-lyh
diff src/error.cc @ 7252:d35fa45980c6
[project @ 2007-12-04 19:02:46 by jwe]
author | jwe |
---|---|
date | Tue, 04 Dec 2007 19:02:46 +0000 |
parents | 6e4ceeeb1940 |
children | 745a8299c2b5 5426a55a0cac |
line wrap: on
line diff
--- a/src/error.cc +++ b/src/error.cc @@ -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 (),