diff doc/interpreter/program.texi @ 2621:337a09dd1c06

[project @ 1997-01-24 21:49:41 by jwe]
author jwe
date Fri, 24 Jan 1997 21:55:06 +0000
parents f201716926bb
children e7908588548a
line wrap: on
line diff
--- a/doc/interpreter/program.texi
+++ b/doc/interpreter/program.texi
@@ -283,19 +283,35 @@
 0.
 @end deftypefn
 
-@deftypefn {Built-in Function} {} error (@var{msg})
-Print the message @var{msg}, prefixed by the string @samp{error: }, and
-set Octave's internal error state such that control will return to the
-top level without evaluating any more commands.  This is useful for
-aborting from functions.
+@deftypefn {Built-in Function} {} error (@var{template}, @dots{})
+The @code{error} function formats the optional arguments under the
+control of the template string @var{template} using the same rules as
+the @code{printf} family of functions (@pxref{Formatted Output}).
+The resulting message is prefixed by the string @samp{error: } and
+printed on the @code{stderr} stream.
 
-If @var{msg} does not end with a new line character, Octave will print a
-traceback of all the function calls leading to the error.  For example,
+Calling @code{error} also sets Octave's internal error state such that
+control will return to the top level without evaluating any more
+commands.  This is useful for aborting from functions or scripts.
+
+If the error message does not end with a new line character, Octave will
+print a traceback of all the function calls leading to the error.  For
+example, given the following function definitions:
 
 @example
+@group
 function f () g () end
 function g () h () end
 function h () nargin == 1 || error ("nargin != 1"); end
+@end group
+@end example
+
+@noindent
+calling the function @code{f()} will result in a list of messages that
+can help you to quickly locate the exact location of the error:
+
+@example
+@group
 f ()
 error: nargin != 1
 error: evaluating index expression near line 1, column 30
@@ -303,22 +319,21 @@
 error: called from `h'
 error: called from `g'
 error: called from `f'
+@end group
 @end example
 
-@noindent
-produces a list of messages that can help you to quickly locate the
-exact location of the error.
-
-If @var{msg} ends in a new line character, Octave will only print
-@var{msg} and will not display any traceback messages as it returns
+If the error message ends in a new line character, Octave will print the
+message but will not display any traceback messages as it returns
 control to the top level.  For example, modifying the error message
 in the previous example to end in a new line causes Octave to only print
 a single message:
 
 @example
+@group
 function h () nargin == 1 || error ("nargin != 1\n"); end
 f ()
 error: nargin != 1
+@end group
 @end example
 @end deftypefn