comparison src/error.cc @ 528:e1e6e33e26f8

[project @ 1994-07-20 18:53:50 by jwe] ,.
author jwe
date Wed, 20 Jul 1994 18:53:50 +0000
parents 20d2061944ee
children bc813f5eb025
comparison
equal deleted inserted replaced
527:6898f0c9e096 528:e1e6e33e26f8
30 #include <stdarg.h> 30 #include <stdarg.h>
31 31
32 #include "utils.h" 32 #include "utils.h"
33 #include "error.h" 33 #include "error.h"
34 #include "pager.h" 34 #include "pager.h"
35 #include "oct-obj.h"
36 #include "tree-const.h"
37 #include "defun.h"
35 38
36 // Current error state. 39 // Current error state.
37 int error_state; 40 int error_state;
38 41
39 static void 42 static void
40 verror (const char *name, const char *fmt, va_list args) 43 verror (const char *name, const char *fmt, va_list args)
41 { 44 {
42 if (name != (char *) NULL) 45 if (name)
43 fprintf (stderr, "%s: ", name); 46 fprintf (stderr, "%s: ", name);
44 47
45 vfprintf (stderr, fmt, args); 48 vfprintf (stderr, fmt, args);
46 fprintf (stderr, "\n"); 49 fprintf (stderr, "\n");
47 fflush (stderr); 50 fflush (stderr);
113 verror ("panic", fmt, args); 116 verror ("panic", fmt, args);
114 va_end (args); 117 va_end (args);
115 abort (); 118 abort ();
116 } 119 }
117 120
121 DEFUN ("error", Ferror, Serror, 2, 1,
122 "error (MESSAGE): print MESSAGE and set the error state.\n\
123 This should eventually take us up to the top level, possibly\n\
124 printing traceback messages as we go.\n\
125 \n\
126 If MESSAGE ends in a newline character, traceback messages are not\n\
127 printed.")
128 {
129 Octave_object retval;
130
131 char *msg = "unspecified_error";
132
133 int nargin = args.length ();
134
135 if (nargin == 2 && args(1).is_defined ())
136 {
137 if (args(1).is_string_type ())
138 {
139 msg = args(1).string_value ();
140
141 if (! msg || ! *msg)
142 return retval;
143 }
144 else if (args(1).is_empty ())
145 return retval;
146 }
147
148 error (msg);
149
150 return retval;
151 }
152
118 /* 153 /*
119 ;;; Local Variables: *** 154 ;;; Local Variables: ***
120 ;;; mode: C++ *** 155 ;;; mode: C++ ***
121 ;;; page-delimiter: "^/\\*" *** 156 ;;; page-delimiter: "^/\\*" ***
122 ;;; End: *** 157 ;;; End: ***