# HG changeset patch # User jwe # Date 774730430 0 # Node ID e1e6e33e26f8f75419950f5ee17ec6451abbd6fe # Parent 6898f0c9e096d763d3e56901b48a46cca2fc6910 [project @ 1994-07-20 18:53:50 by jwe] ,. diff -r 6898f0c9e096 -r e1e6e33e26f8 src/error.cc --- a/src/error.cc Wed Jul 20 18:53:27 1994 +0000 +++ b/src/error.cc Wed Jul 20 18:53:50 1994 +0000 @@ -32,6 +32,9 @@ #include "utils.h" #include "error.h" #include "pager.h" +#include "oct-obj.h" +#include "tree-const.h" +#include "defun.h" // Current error state. int error_state; @@ -39,7 +42,7 @@ static void verror (const char *name, const char *fmt, va_list args) { - if (name != (char *) NULL) + if (name) fprintf (stderr, "%s: ", name); vfprintf (stderr, fmt, args); @@ -115,6 +118,38 @@ abort (); } +DEFUN ("error", Ferror, Serror, 2, 1, + "error (MESSAGE): print MESSAGE and set the error state.\n\ +This should eventually take us up to the top level, possibly\n\ +printing traceback messages as we go.\n\ +\n\ +If MESSAGE ends in a newline character, traceback messages are not\n\ +printed.") +{ + Octave_object retval; + + char *msg = "unspecified_error"; + + int nargin = args.length (); + + if (nargin == 2 && args(1).is_defined ()) + { + if (args(1).is_string_type ()) + { + msg = args(1).string_value (); + + if (! msg || ! *msg) + return retval; + } + else if (args(1).is_empty ()) + return retval; + } + + error (msg); + + return retval; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***