changeset 528:e1e6e33e26f8

[project @ 1994-07-20 18:53:50 by jwe] ,.
author jwe
date Wed, 20 Jul 1994 18:53:50 +0000
parents 6898f0c9e096
children 7ea224e713cd
files src/error.cc
diffstat 1 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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++ ***