Mercurial > octave-nkf
annotate src/error.cc @ 9166:69088b7b139c
use complete stack trace information for lasterror
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 01 May 2009 14:00:54 -0400 |
parents | 5247e89688e1 |
children | ba7f45642ffe |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
8920 | 4 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
240 | 24 #ifdef HAVE_CONFIG_H |
1192 | 25 #include <config.h> |
1 | 26 #endif |
27 | |
1343 | 28 #include <cstdarg> |
1633 | 29 #include <cstring> |
1343 | 30 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
31 #include <iostream> |
5765 | 32 #include <sstream> |
1728 | 33 #include <string> |
34 | |
1352 | 35 #include "defun.h" |
1 | 36 #include "error.h" |
3707 | 37 #include "input.h" |
1742 | 38 #include "pager.h" |
1352 | 39 #include "oct-obj.h" |
5567 | 40 #include "oct-map.h" |
1352 | 41 #include "utils.h" |
2370 | 42 #include "ov.h" |
3707 | 43 #include "ov-usr-fcn.h" |
44 #include "pt-pr-code.h" | |
45 #include "pt-stmt.h" | |
46 #include "toplev.h" | |
47 #include "unwind-prot.h" | |
2370 | 48 #include "variables.h" |
1 | 49 |
2174 | 50 // TRUE means that Octave will try to beep obnoxiously before printing |
51 // error messages. | |
5794 | 52 static bool Vbeep_on_error = false; |
2174 | 53 |
3707 | 54 // TRUE means that Octave will try to enter the debugger when an error |
55 // is encountered. This will also inhibit printing of the normal | |
56 // traceback message (you will only see the top-level error message). | |
7353 | 57 bool Vdebug_on_error = false; |
3707 | 58 |
59 // TRUE means that Octave will try to enter the debugger when a warning | |
60 // is encountered. | |
7353 | 61 bool Vdebug_on_warning = false; |
3707 | 62 |
5567 | 63 // TRUE means that Octave will try to display a stack trace when a |
64 // warning is encountered. | |
65 static bool Vbacktrace_on_warning = false; | |
66 | |
67 // TRUE means that Octave will print a verbose warning. Currently unused. | |
68 static bool Vverbose_warning; | |
69 | |
5582 | 70 // TRUE means that Octave will print no warnings, but lastwarn will be |
71 //updated | |
72 static bool Vquiet_warning = false; | |
73 | |
5567 | 74 // A structure containing (most of) the current state of warnings. |
75 static Octave_map warning_options; | |
76 | |
3935 | 77 // The text of the last error message. |
78 static std::string Vlast_error_message; | |
79 | |
3934 | 80 // The text of the last warning message. |
81 static std::string Vlast_warning_message; | |
82 | |
5567 | 83 // The last warning message id. |
84 static std::string Vlast_warning_id; | |
3934 | 85 |
5567 | 86 // The last error message id. |
87 static std::string Vlast_error_id; | |
3934 | 88 |
6361 | 89 // The last file in which an error occured |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
90 static Octave_map Vlast_error_stack; |
6361 | 91 |
143 | 92 // Current error state. |
3935 | 93 // |
94 // Valid values: | |
95 // | |
96 // -2: an error has occurred, but don't print any messages. | |
97 // -1: an error has occurred, we are printing a traceback | |
98 // 0: no error | |
99 // 1: an error has occurred | |
100 // | |
672 | 101 int error_state = 0; |
102 | |
3489 | 103 // Current warning state. |
3935 | 104 // |
105 // Valid values: | |
106 // | |
107 // 0: no warning | |
108 // 1: a warning has occurred | |
109 // | |
3489 | 110 int warning_state = 0; |
111 | |
1489 | 112 // Tell the error handler whether to print messages, or just store |
113 // them for later. Used for handling errors in eval() and | |
114 // the `unwind_protect' statement. | |
4699 | 115 int buffer_error_messages = 0; |
1489 | 116 |
3815 | 117 // TRUE means error messages are turned off. |
118 bool discard_error_messages = false; | |
119 | |
4452 | 120 // TRUE means warning messages are turned off. |
121 bool discard_warning_messages = false; | |
122 | |
3811 | 123 // The message buffer. |
5765 | 124 static std::ostringstream *error_message_buffer = 0; |
143 | 125 |
4318 | 126 void |
127 reset_error_handler (void) | |
128 { | |
129 error_state = 0; | |
130 warning_state = 0; | |
4699 | 131 buffer_error_messages = 0; |
4318 | 132 discard_error_messages = false; |
133 } | |
134 | |
5567 | 135 static void |
5794 | 136 initialize_warning_options (const std::string& state) |
5567 | 137 { |
138 warning_options.clear (); | |
139 | |
140 warning_options.assign ("identifier", "all"); | |
141 warning_options.assign ("state", state); | |
142 } | |
143 | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
144 static Octave_map |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
145 initialize_last_error_stack (void) |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
146 { |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
147 static bool initialized = false; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
148 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
149 static string_vector sv (4); |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
150 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
151 if (! initialized) |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
152 { |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
153 sv[0] = "file"; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
154 sv[1] = "name"; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
155 sv[2] = "line"; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
156 sv[3] = "column"; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
157 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
158 initialized = true; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
159 } |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
160 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
161 return Octave_map (dim_vector (0, 1), sv); |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
162 } |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
163 |
3491 | 164 // Warning messages are never buffered. |
165 | |
166 static void | |
5567 | 167 vwarning (const char *name, const char *id, const char *fmt, va_list args) |
3491 | 168 { |
4452 | 169 if (discard_warning_messages) |
170 return; | |
171 | |
3491 | 172 flush_octave_stdout (); |
173 | |
5765 | 174 std::ostringstream output_buf; |
3491 | 175 |
176 if (name) | |
3761 | 177 output_buf << name << ": "; |
178 | |
179 octave_vformat (output_buf, fmt, args); | |
180 | |
5765 | 181 output_buf << std::endl; |
3491 | 182 |
5775 | 183 // FIXME -- we really want to capture the message before it |
3935 | 184 // has all the formatting goop attached to it. We probably also |
185 // want just the message, not the traceback information. | |
186 | |
5765 | 187 std::string msg_string = output_buf.str (); |
3934 | 188 |
3935 | 189 if (! warning_state) |
190 { | |
191 // This is the first warning in a possible series. | |
5567 | 192 |
193 Vlast_warning_id = id; | |
3935 | 194 Vlast_warning_message = msg_string; |
195 } | |
3934 | 196 |
5582 | 197 if (! Vquiet_warning) |
198 { | |
199 octave_diary << msg_string; | |
3935 | 200 |
5582 | 201 std::cerr << msg_string; |
202 } | |
3491 | 203 } |
204 | |
1 | 205 static void |
4732 | 206 verror (bool save_last_error, std::ostream& os, |
5567 | 207 const char *name, const char *id, const char *fmt, va_list args) |
1 | 208 { |
3815 | 209 if (discard_error_messages) |
210 return; | |
211 | |
3585 | 212 if (! buffer_error_messages) |
213 flush_octave_stdout (); | |
914 | 214 |
5775 | 215 // FIXME -- we really want to capture the message before it |
3935 | 216 // has all the formatting goop attached to it. We probably also |
217 // want just the message, not the traceback information. | |
218 | |
7877 | 219 std::ostringstream output_buf; |
220 | |
221 octave_vformat (output_buf, fmt, args); | |
222 | |
223 std::string base_msg = output_buf.str (); | |
224 | |
225 bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state; | |
226 | |
227 std::string msg_string; | |
228 | |
229 if (to_beep_or_not_to_beep_p) | |
230 msg_string = "\a"; | |
231 | |
232 if (name) | |
233 msg_string += std::string (name) + ": "; | |
234 | |
7880 | 235 msg_string += base_msg + "\n"; |
3935 | 236 |
4731 | 237 if (! error_state && save_last_error) |
3935 | 238 { |
239 // This is the first error in a possible series. | |
5567 | 240 |
241 Vlast_error_id = id; | |
7877 | 242 Vlast_error_message = base_msg; |
6361 | 243 |
7877 | 244 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
6361 | 245 |
7877 | 246 if (fcn) |
247 { | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
248 octave_idx_type curr_frame = -1; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
249 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
250 Vlast_error_stack = octave_call_stack::backtrace (0, curr_frame); |
6361 | 251 } |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
252 else |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
253 Vlast_error_stack = initialize_last_error_stack (); |
3935 | 254 } |
255 | |
1489 | 256 if (buffer_error_messages) |
257 { | |
7882 | 258 if (error_message_buffer) |
259 msg_string = "error: " + msg_string; | |
260 else | |
7880 | 261 error_message_buffer = new std::ostringstream (); |
1489 | 262 |
7880 | 263 *error_message_buffer << msg_string; |
1489 | 264 } |
265 else | |
266 { | |
3935 | 267 octave_diary << msg_string; |
4732 | 268 os << msg_string; |
1489 | 269 } |
1 | 270 } |
271 | |
1266 | 272 // Note that we don't actually print any message if the error string |
273 // is just "" or "\n". This allows error ("") and error ("\n") to | |
274 // just set the error state. | |
275 | |
1005 | 276 static void |
5567 | 277 error_1 (std::ostream& os, const char *name, const char *id, |
278 const char *fmt, va_list args) | |
1005 | 279 { |
280 if (error_state != -2) | |
281 { | |
1489 | 282 if (fmt) |
1005 | 283 { |
1489 | 284 if (*fmt) |
1005 | 285 { |
1489 | 286 int len = strlen (fmt); |
287 if (fmt[len - 1] == '\n') | |
1266 | 288 { |
1489 | 289 if (len > 1) |
1266 | 290 { |
1489 | 291 char *tmp_fmt = strsave (fmt); |
292 tmp_fmt[len - 1] = '\0'; | |
5567 | 293 verror (true, os, name, id, tmp_fmt, args); |
1489 | 294 delete [] tmp_fmt; |
295 } | |
1423 | 296 |
1489 | 297 error_state = -2; |
1266 | 298 } |
1489 | 299 else |
5567 | 300 verror (true, os, name, id, fmt, args); |
1005 | 301 } |
302 } | |
1489 | 303 else |
304 panic ("error_1: invalid format"); | |
1423 | 305 |
306 if (! error_state) | |
307 error_state = 1; | |
1005 | 308 } |
309 } | |
310 | |
1 | 311 void |
6338 | 312 vmessage (const char *name, const char *fmt, va_list args) |
313 { | |
314 verror (false, std::cerr, name, "", fmt, args); | |
315 } | |
316 | |
317 void | |
1 | 318 message (const char *name, const char *fmt, ...) |
319 { | |
320 va_list args; | |
321 va_start (args, fmt); | |
6338 | 322 vmessage (name, fmt, args); |
1 | 323 va_end (args); |
324 } | |
325 | |
326 void | |
6338 | 327 vmessage_with_id (const char *name, const char *id, const char *fmt, |
328 va_list args) | |
329 { | |
330 verror (false, std::cerr, name, id, fmt, args); | |
331 } | |
332 | |
333 void | |
5567 | 334 message_with_id (const char *name, const char *id, const char *fmt, ...) |
335 { | |
336 va_list args; | |
337 va_start (args, fmt); | |
6338 | 338 vmessage_with_id (name, id, fmt, args); |
5567 | 339 va_end (args); |
340 } | |
341 | |
342 void | |
343 usage_1 (const char *id, const char *fmt, va_list args) | |
344 { | |
345 verror (true, std::cerr, "usage", id, fmt, args); | |
346 error_state = -1; | |
347 } | |
348 | |
349 void | |
6338 | 350 vusage (const char *fmt, va_list args) |
351 { | |
352 usage_1 ("", fmt, args); | |
353 } | |
354 | |
355 void | |
1 | 356 usage (const char *fmt, ...) |
357 { | |
358 va_list args; | |
359 va_start (args, fmt); | |
6338 | 360 vusage (fmt, args); |
5567 | 361 va_end (args); |
362 } | |
363 | |
364 void | |
6338 | 365 vusage_with_id (const char *id, const char *fmt, va_list args) |
366 { | |
367 usage_1 (id, fmt, args); | |
368 } | |
369 | |
370 void | |
5567 | 371 usage_with_id (const char *id, const char *fmt, ...) |
372 { | |
373 va_list args; | |
374 va_start (args, fmt); | |
6338 | 375 vusage_with_id (id, fmt, args); |
1 | 376 va_end (args); |
377 } | |
378 | |
3707 | 379 static void |
3719 | 380 pr_where_2 (const char *fmt, va_list args) |
381 { | |
382 if (fmt) | |
383 { | |
384 if (*fmt) | |
385 { | |
386 int len = strlen (fmt); | |
387 if (fmt[len - 1] == '\n') | |
388 { | |
389 if (len > 1) | |
390 { | |
391 char *tmp_fmt = strsave (fmt); | |
392 tmp_fmt[len - 1] = '\0'; | |
5567 | 393 verror (false, std::cerr, 0, "", tmp_fmt, args); |
3719 | 394 delete [] tmp_fmt; |
395 } | |
396 } | |
397 else | |
5567 | 398 verror (false, std::cerr, 0, "", fmt, args); |
3719 | 399 } |
400 } | |
401 else | |
402 panic ("pr_where_2: invalid format"); | |
403 } | |
404 | |
405 static void | |
3707 | 406 pr_where_1 (const char *fmt, ...) |
407 { | |
408 va_list args; | |
409 va_start (args, fmt); | |
3719 | 410 pr_where_2 (fmt, args); |
3707 | 411 va_end (args); |
412 } | |
413 | |
414 static void | |
8973 | 415 pr_where (const char *who) |
3707 | 416 { |
8973 | 417 octave_idx_type curr_frame = -1; |
3707 | 418 |
8973 | 419 Octave_map stk = octave_call_stack::backtrace (0, curr_frame); |
4976 | 420 |
8973 | 421 octave_idx_type nframes_to_display = stk.numel (); |
4976 | 422 |
8973 | 423 if (nframes_to_display > 0) |
424 { | |
425 pr_where_1 ("%s: called from\n", who); | |
3708 | 426 |
8973 | 427 Cell names = stk.contents ("name"); |
428 Cell lines = stk.contents ("line"); | |
429 Cell columns = stk.contents ("column"); | |
3707 | 430 |
8973 | 431 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
4976 | 432 { |
8973 | 433 octave_value name = names(i); |
434 octave_value line = lines(i); | |
435 octave_value column = columns(i); | |
3707 | 436 |
8973 | 437 std::string nm = name.string_value (); |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7353
diff
changeset
|
438 |
8973 | 439 pr_where_1 (" %s at line %d column %d\n", nm.c_str (), |
440 line.int_value (), column.int_value ()); | |
4719 | 441 } |
3707 | 442 } |
443 } | |
444 | |
6000 | 445 static void |
446 error_2 (const char *id, const char *fmt, va_list args) | |
447 { | |
448 int init_state = error_state; | |
449 | |
450 error_1 (std::cerr, "error", id, fmt, args); | |
451 | |
452 if ((interactive || forced_interactive) | |
453 && Vdebug_on_error && init_state == 0 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
454 && octave_call_stack::caller_user_code ()) |
6000 | 455 { |
456 unwind_protect_bool (Vdebug_on_error); | |
457 Vdebug_on_error = false; | |
458 | |
8973 | 459 error_state = 0; |
6000 | 460 |
8973 | 461 pr_where ("error"); |
6000 | 462 |
463 do_keyboard (octave_value_list ()); | |
464 | |
465 unwind_protect::run (); | |
466 } | |
467 } | |
468 | |
469 void | |
6338 | 470 verror (const char *fmt, va_list args) |
471 { | |
472 error_2 ("", fmt, args); | |
473 } | |
474 | |
475 void | |
6000 | 476 error (const char *fmt, ...) |
477 { | |
478 va_list args; | |
479 va_start (args, fmt); | |
6338 | 480 verror (fmt, args); |
6000 | 481 va_end (args); |
482 } | |
483 | |
484 void | |
6338 | 485 verror_with_id (const char *id, const char *fmt, va_list args) |
486 { | |
487 error_2 (id, fmt, args); | |
488 } | |
489 | |
490 void | |
6000 | 491 error_with_id (const char *id, const char *fmt, ...) |
492 { | |
493 va_list args; | |
494 va_start (args, fmt); | |
6338 | 495 verror_with_id (id, fmt, args); |
6000 | 496 va_end (args); |
497 } | |
498 | |
5567 | 499 static int |
500 check_state (const std::string& state) | |
501 { | |
502 // -1: not found | |
503 // 0: found, "off" | |
504 // 1: found, "on" | |
505 // 2: found, "error" | |
506 | |
507 if (state == "off") | |
508 return 0; | |
509 else if (state == "on") | |
510 return 1; | |
511 else if (state == "error") | |
512 return 2; | |
513 else | |
514 return -1; | |
515 } | |
516 | |
517 // For given warning ID, return 0 if warnings are disabled, 1 if | |
518 // enabled, and 2 if this ID should be an error instead of a warning. | |
519 | |
5781 | 520 int |
5567 | 521 warning_enabled (const std::string& id) |
1 | 522 { |
5567 | 523 int retval = 0; |
524 | |
525 int all_state = -1; | |
526 int id_state = -1; | |
527 | |
528 octave_idx_type nel = warning_options.numel (); | |
529 | |
530 if (nel > 0) | |
531 { | |
532 Cell identifier = warning_options.contents ("identifier"); | |
533 Cell state = warning_options.contents ("state"); | |
534 | |
535 bool all_found = false; | |
536 bool id_found = false; | |
537 | |
538 for (octave_idx_type i = 0; i < nel; i++) | |
539 { | |
540 octave_value ov = identifier(i); | |
541 std::string ovs = ov.string_value (); | |
542 | |
543 if (! all_found && ovs == "all") | |
544 { | |
545 all_state = check_state (state(i).string_value ()); | |
546 | |
547 if (all_state >= 0) | |
548 all_found = true; | |
549 } | |
550 | |
551 if (! id_found && ovs == id) | |
552 { | |
553 id_state = check_state (state(i).string_value ()); | |
554 | |
555 if (id_state >= 0) | |
556 id_found = true; | |
557 } | |
558 | |
559 if (all_found && id_found) | |
560 break; | |
561 } | |
562 } | |
563 | |
564 if (all_state == -1) | |
565 panic_impossible (); | |
566 | |
567 if (all_state == 0) | |
568 { | |
569 if (id_state >= 0) | |
570 retval = id_state; | |
571 } | |
572 else if (all_state == 1) | |
573 { | |
574 if (id_state == 0 || id_state == 2) | |
575 retval = id_state; | |
576 else | |
577 retval = all_state; | |
578 } | |
579 else if (all_state == 2) | |
7206 | 580 { |
581 if (id_state == 0) | |
582 retval= id_state; | |
583 else | |
584 retval = all_state; | |
585 } | |
5567 | 586 |
587 return retval; | |
588 } | |
589 | |
590 static void | |
591 warning_1 (const char *id, const char *fmt, va_list args) | |
592 { | |
593 int warn_opt = warning_enabled (id); | |
594 | |
595 if (warn_opt == 2) | |
596 { | |
597 // Handle this warning as an error. | |
598 | |
5998 | 599 error_2 (id, fmt, args); |
5567 | 600 } |
601 else if (warn_opt == 1) | |
3934 | 602 { |
8973 | 603 vwarning ("warning", id, fmt, args); |
604 | |
605 if (! symbol_table::at_top_level () | |
5567 | 606 && Vbacktrace_on_warning |
4452 | 607 && ! warning_state |
608 && ! discard_warning_messages) | |
8973 | 609 pr_where ("warning"); |
3707 | 610 |
3935 | 611 warning_state = 1; |
612 | |
3934 | 613 if ((interactive || forced_interactive) |
5743 | 614 && Vdebug_on_warning |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
615 && octave_call_stack::caller_user_code ()) |
3934 | 616 { |
617 unwind_protect_bool (Vdebug_on_warning); | |
618 Vdebug_on_warning = false; | |
3707 | 619 |
3934 | 620 do_keyboard (octave_value_list ()); |
3707 | 621 |
3934 | 622 unwind_protect::run (); |
623 } | |
3707 | 624 } |
1 | 625 } |
626 | |
627 void | |
6338 | 628 vwarning (const char *fmt, va_list args) |
629 { | |
630 warning_1 ("", fmt, args); | |
631 } | |
632 | |
633 void | |
5567 | 634 warning (const char *fmt, ...) |
635 { | |
636 va_list args; | |
637 va_start (args, fmt); | |
6338 | 638 vwarning (fmt, args); |
5567 | 639 va_end (args); |
640 } | |
641 | |
642 void | |
6338 | 643 vwarning_with_id (const char *id, const char *fmt, va_list args) |
644 { | |
645 warning_1 (id, fmt, args); | |
646 } | |
647 | |
648 void | |
5567 | 649 warning_with_id (const char *id, const char *fmt, ...) |
650 { | |
651 va_list args; | |
652 va_start (args, fmt); | |
6338 | 653 vwarning_with_id (id, fmt, args); |
5567 | 654 va_end (args); |
655 } | |
656 | |
657 void | |
6338 | 658 vparse_error (const char *fmt, va_list args) |
659 { | |
660 error_1 (std::cerr, 0, "", fmt, args); | |
661 } | |
662 | |
663 void | |
1005 | 664 parse_error (const char *fmt, ...) |
665 { | |
666 va_list args; | |
667 va_start (args, fmt); | |
6338 | 668 vparse_error (fmt, args); |
5567 | 669 va_end (args); |
670 } | |
671 | |
672 void | |
6338 | 673 vparse_error_with_id (const char *id, const char *fmt, va_list args) |
674 { | |
675 error_1 (std::cerr, 0, id, fmt, args); | |
676 } | |
677 | |
678 void | |
5567 | 679 parse_error_with_id (const char *id, const char *fmt, ...) |
680 { | |
681 va_list args; | |
682 va_start (args, fmt); | |
6338 | 683 vparse_error_with_id (id, fmt, args); |
1 | 684 va_end (args); |
685 } | |
686 | |
189 | 687 void |
6361 | 688 rethrow_error (const char *id, const char *fmt, ...) |
689 { | |
690 va_list args; | |
691 va_start (args, fmt); | |
6640 | 692 error_1 (std::cerr, 0, id, fmt, args); |
6361 | 693 va_end (args); |
694 } | |
695 | |
696 void | |
1 | 697 panic (const char *fmt, ...) |
698 { | |
699 va_list args; | |
700 va_start (args, fmt); | |
4699 | 701 buffer_error_messages = 0; |
3815 | 702 discard_error_messages = false; |
5567 | 703 verror (false, std::cerr, "panic", "", fmt, args); |
1 | 704 va_end (args); |
705 abort (); | |
706 } | |
707 | |
4732 | 708 static void |
709 defun_usage_message_1 (const char *fmt, ...) | |
710 { | |
711 va_list args; | |
712 va_start (args, fmt); | |
5567 | 713 error_1 (octave_stdout, 0, "", fmt, args); |
4732 | 714 va_end (args); |
715 } | |
716 | |
717 void | |
718 defun_usage_message (const std::string& msg) | |
719 { | |
720 defun_usage_message_1 ("%s", msg.c_str ()); | |
721 } | |
722 | |
5567 | 723 typedef void (*error_fun)(const char *, const char *, ...); |
1489 | 724 |
2086 | 725 extern octave_value_list Fsprintf (const octave_value_list&, int); |
1489 | 726 |
3934 | 727 static std::string |
5567 | 728 handle_message (error_fun f, const char *id, const char *msg, |
729 const octave_value_list& args) | |
528 | 730 { |
3934 | 731 std::string retval; |
528 | 732 |
3523 | 733 std::string tstr; |
1728 | 734 |
528 | 735 int nargin = args.length (); |
736 | |
2745 | 737 if (nargin > 0) |
528 | 738 { |
3066 | 739 octave_value arg; |
740 | |
741 if (nargin > 1) | |
742 { | |
743 octave_value_list tmp = Fsprintf (args, 1); | |
744 arg = tmp(0); | |
745 } | |
746 else | |
747 arg = args(0); | |
2745 | 748 |
749 if (arg.is_defined ()) | |
528 | 750 { |
2745 | 751 if (arg.is_string ()) |
752 { | |
753 tstr = arg.string_value (); | |
754 msg = tstr.c_str (); | |
755 | |
756 if (! msg) | |
757 return retval; | |
758 } | |
759 else if (arg.is_empty ()) | |
528 | 760 return retval; |
761 } | |
762 } | |
763 | |
1489 | 764 // Ugh. |
765 | |
766 int len = strlen (msg); | |
767 if (msg[len - 1] == '\n') | |
768 { | |
769 if (len > 1) | |
770 { | |
771 char *tmp_msg = strsave (msg); | |
772 tmp_msg[len - 1] = '\0'; | |
5567 | 773 f (id, "%s\n", tmp_msg); |
3934 | 774 retval = tmp_msg; |
1489 | 775 delete [] tmp_msg; |
776 } | |
777 } | |
778 else | |
3934 | 779 { |
5567 | 780 f (id, "%s", msg); |
3934 | 781 retval = msg; |
782 } | |
528 | 783 |
784 return retval; | |
785 } | |
786 | |
6361 | 787 DEFUN (rethrow, args, , |
788 "-*- texinfo -*-\n\ | |
789 @deftypefn {Built-in Function} {} rethrow (@var{err})\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
790 Reissues a previous error as defined by @var{err}. @var{err} is a structure\n\ |
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
791 that must contain at least the 'message' and 'identifier' fields. @var{err}\n\ |
6361 | 792 can also contain a field 'stack' that gives information on the assumed\n\ |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
793 location of the error. Typically @var{err} is returned from\n\ |
6361 | 794 @code{lasterror}.\n\ |
795 @seealso{lasterror, lasterr, error}\n\ | |
796 @end deftypefn") | |
797 { | |
798 octave_value retval; | |
799 int nargin = args.length(); | |
800 | |
801 if (nargin != 1) | |
6959 | 802 print_usage (); |
6361 | 803 else |
804 { | |
6483 | 805 Octave_map err = args(0).map_value (); |
6361 | 806 |
6483 | 807 if (! error_state) |
6361 | 808 { |
6483 | 809 if (err.contains ("message") && err.contains ("identifier")) |
6361 | 810 { |
6483 | 811 std::string msg = err.contents("message")(0).string_value (); |
812 std::string id = err.contents("identifier")(0).string_value (); | |
6361 | 813 int len = msg.length(); |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
814 |
6361 | 815 std::string file; |
816 std::string nm; | |
817 int l = -1; | |
818 int c = -1; | |
819 | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
820 Octave_map err_stack = initialize_last_error_stack (); |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
821 |
6483 | 822 if (err.contains ("stack")) |
6361 | 823 { |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
824 err_stack = err.contents("stack")(0).map_value (); |
6483 | 825 |
6640 | 826 if (err_stack.numel () > 0) |
827 { | |
828 if (err_stack.contains ("file")) | |
829 file = err_stack.contents("file")(0).string_value (); | |
6483 | 830 |
6640 | 831 if (err_stack.contains ("name")) |
832 nm = err_stack.contents("name")(0).string_value (); | |
6483 | 833 |
6640 | 834 if (err_stack.contains ("line")) |
835 l = err_stack.contents("line")(0).nint_value (); | |
836 | |
837 if (err_stack.contains ("column")) | |
838 c = err_stack.contents("column")(0).nint_value (); | |
839 } | |
6361 | 840 } |
841 | |
842 // Ugh. | |
6483 | 843 char *tmp_msg = strsave (msg.c_str ()); |
6361 | 844 if (tmp_msg[len-1] == '\n') |
845 { | |
846 if (len > 1) | |
847 { | |
848 tmp_msg[len - 1] = '\0'; | |
6483 | 849 rethrow_error (id.c_str (), "%s\n", tmp_msg); |
6361 | 850 } |
851 } | |
852 else | |
6483 | 853 rethrow_error (id.c_str (), "%s", tmp_msg); |
6361 | 854 delete [] tmp_msg; |
855 | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
856 // FIXME -- is this the right thing to do for |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
857 // Vlast_error_stack? Should it be saved and restored |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
858 // with unwind_protect? |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
859 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
860 Vlast_error_stack = err_stack; |
6361 | 861 |
6483 | 862 if (err.contains ("stack")) |
6361 | 863 { |
864 if (file.empty ()) | |
865 { | |
866 if (nm.empty ()) | |
867 { | |
868 if (l > 0) | |
6483 | 869 { |
870 if (c > 0) | |
871 pr_where_1 ("error: near line %d, column %d", | |
872 l, c); | |
873 else | |
874 pr_where_1 ("error: near line %d", l); | |
875 } | |
6361 | 876 } |
877 else | |
878 { | |
879 if (l > 0) | |
6483 | 880 { |
881 if (c > 0) | |
882 pr_where_1 ("error: called from `%s' near line %d, column %d", | |
883 nm.c_str (), l, c); | |
884 else | |
885 pr_where_1 ("error: called from `%d' near line %d", nm.c_str (), l); | |
886 } | |
6361 | 887 } |
888 } | |
889 else | |
890 { | |
891 if (nm.empty ()) | |
892 { | |
893 if (l > 0) | |
6483 | 894 { |
895 if (c > 0) | |
896 pr_where_1 ("error: in file %s near line %d, column %d", | |
897 file.c_str (), l, c); | |
898 else | |
899 pr_where_1 ("error: in file %s near line %d", file.c_str (), l); | |
900 } | |
6361 | 901 } |
902 else | |
903 { | |
904 if (l > 0) | |
6483 | 905 { |
906 if (c > 0) | |
907 pr_where_1 ("error: called from `%s' in file %s near line %d, column %d", | |
908 nm.c_str (), file.c_str (), l, c); | |
909 else | |
910 pr_where_1 ("error: called from `%d' in file %s near line %d", nm.c_str (), file.c_str (), l); | |
911 } | |
6361 | 912 } |
913 } | |
914 } | |
915 } | |
916 else | |
917 error ("rethrow: structure must contain the fields 'message and 'identifier'"); | |
918 } | |
919 } | |
920 return retval; | |
921 } | |
922 | |
1957 | 923 DEFUN (error, args, , |
3373 | 924 "-*- texinfo -*-\n\ |
925 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\ | |
7252 | 926 @deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\ |
5781 | 927 Format the optional arguments under the control of the template string\n\ |
928 @var{template} using the same rules as the @code{printf} family of\n\ | |
929 functions (@pxref{Formatted Output}) and print the resulting message\n\ | |
930 on the @code{stderr} stream. The message is prefixed by the character\n\ | |
931 string @samp{error: }.\n\ | |
3373 | 932 \n\ |
933 Calling @code{error} also sets Octave's internal error state such that\n\ | |
934 control will return to the top level without evaluating any more\n\ | |
935 commands. This is useful for aborting from functions or scripts.\n\ | |
897 | 936 \n\ |
3373 | 937 If the error message does not end with a new line character, Octave will\n\ |
938 print a traceback of all the function calls leading to the error. For\n\ | |
939 example, given the following function definitions:\n\ | |
940 \n\ | |
941 @example\n\ | |
942 @group\n\ | |
6671 | 943 function f () g (); end\n\ |
944 function g () h (); end\n\ | |
3373 | 945 function h () nargin == 1 || error (\"nargin != 1\"); end\n\ |
946 @end group\n\ | |
947 @end example\n\ | |
1489 | 948 \n\ |
3373 | 949 @noindent\n\ |
950 calling the function @code{f} will result in a list of messages that\n\ | |
951 can help you to quickly locate the exact location of the error:\n\ | |
1489 | 952 \n\ |
9153
5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
953 @example\n\ |
3373 | 954 @group\n\ |
955 f ()\n\ | |
956 error: nargin != 1\n\ | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
957 error: called from:\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
958 error: error at line -1, column -1\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
959 error: h at line 1, column 27\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
960 error: g at line 1, column 15\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
961 error: f at line 1, column 15\n\ |
3373 | 962 @end group\n\ |
9153
5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
963 @end example\n\ |
3373 | 964 \n\ |
965 If the error message ends in a new line character, Octave will print the\n\ | |
966 message but will not display any traceback messages as it returns\n\ | |
967 control to the top level. For example, modifying the error message\n\ | |
968 in the previous example to end in a new line causes Octave to only print\n\ | |
969 a single message:\n\ | |
970 \n\ | |
971 @example\n\ | |
972 @group\n\ | |
973 function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\ | |
974 f ()\n\ | |
975 error: nargin != 1\n\ | |
976 @end group\n\ | |
977 @end example\n\ | |
978 @end deftypefn") | |
897 | 979 { |
7252 | 980 octave_value retval; |
981 | |
982 int nargin = args.length (); | |
983 | |
984 octave_value_list nargs = args; | |
985 | |
986 std::string id; | |
987 | |
988 if (nargin > 1) | |
989 { | |
990 std::string arg1 = args(0).string_value (); | |
5567 | 991 |
7252 | 992 if (! error_state) |
993 { | |
8021 | 994 if (arg1.find ('%') == std::string::npos) |
7252 | 995 { |
996 id = arg1; | |
997 | |
998 nargs.resize (nargin-1); | |
999 | |
1000 for (int i = 1; i < nargin; i++) | |
1001 nargs(i-1) = args(i); | |
1002 } | |
1003 } | |
1004 else | |
1005 return retval; | |
1006 } | |
1007 | |
1008 handle_message (error_with_id, id.c_str (), "unspecified error", nargs); | |
1009 | |
3934 | 1010 return retval; |
1489 | 1011 } |
897 | 1012 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
1013 DEFUN (warning, args, nargout, |
3373 | 1014 "-*- texinfo -*-\n\ |
5781 | 1015 @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ |
7252 | 1016 @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\ |
5781 | 1017 Format the optional arguments under the control of the template string\n\ |
1018 @var{template} using the same rules as the @code{printf} family of\n\ | |
1019 functions (@pxref{Formatted Output}) and print the resulting message\n\ | |
1020 on the @code{stderr} stream. The message is prefixed by the character\n\ | |
1021 string @samp{warning: }.\n\ | |
1022 You should use this function when you want to notify the user\n\ | |
3600 | 1023 of an unusual condition, but only when it makes sense for your program\n\ |
1024 to go on.\n\ | |
5781 | 1025 \n\ |
1026 The optional message identifier allows users to enable or disable\n\ | |
1027 warnings tagged by @var{id}. The special identifier @samp{\"all\"} may\n\ | |
1028 be used to set the state of all warnings.\n\ | |
1029 \n\ | |
1030 @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\ | |
1031 @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\ | |
1032 @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\ | |
1033 @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\ | |
6653 | 1034 Set or query the state of a particular warning using the identifier\n\ |
5781 | 1035 @var{id}. If the identifier is omitted, a value of @samp{\"all\"} is\n\ |
1036 assumed. If you set the state of a warning to @samp{\"error\"}, the\n\ | |
1037 warning named by @var{id} is handled as if it were an error instead.\n\ | |
5783 | 1038 @seealso{warning_ids}\n\ |
3373 | 1039 @end deftypefn") |
1489 | 1040 { |
5567 | 1041 octave_value retval; |
3934 | 1042 |
5567 | 1043 int nargin = args.length (); |
1044 int argc = nargin + 1; | |
3934 | 1045 |
3935 | 1046 bool done = false; |
3934 | 1047 |
5567 | 1048 if (argc > 1 && args.all_strings_p ()) |
3935 | 1049 { |
1050 string_vector argv = args.make_argv ("warning"); | |
1051 | |
1052 if (! error_state) | |
3934 | 1053 { |
5567 | 1054 std::string arg1 = argv(1); |
1055 std::string arg2 = "all"; | |
1056 | |
1057 if (argc == 3) | |
1058 arg2 = argv(2); | |
1059 | |
1060 if (arg1 == "on" || arg1 == "off" || arg1 == "error") | |
3934 | 1061 { |
5567 | 1062 Octave_map old_warning_options = warning_options; |
1063 | |
1064 if (arg2 == "all") | |
1065 { | |
1066 Octave_map tmp; | |
3934 | 1067 |
7202 | 1068 Cell id (1, 1); |
1069 Cell st (1, 1); | |
1070 | |
1071 id(0) = arg2; | |
1072 st(0) = arg1; | |
1073 | |
1074 // Since internal Octave functions are not | |
1075 // compatible, turning all warnings into errors | |
1076 // should leave the state of | |
1077 // Octave:matlab-incompatible alone. | |
1078 | |
1079 if (arg1 == "error" | |
1080 && warning_options.contains ("identifier")) | |
1081 { | |
7206 | 1082 octave_idx_type n = 1; |
1083 | |
7202 | 1084 Cell tid = warning_options.contents ("identifier"); |
1085 Cell tst = warning_options.contents ("state"); | |
1086 | |
1087 for (octave_idx_type i = 0; i < tid.numel (); i++) | |
1088 { | |
1089 octave_value vid = tid(i); | |
1090 | |
7206 | 1091 if (vid.is_string ()) |
7202 | 1092 { |
7206 | 1093 std::string key = vid.string_value (); |
7202 | 1094 |
7206 | 1095 if (key == "Octave:matlab-incompatible" |
1096 || key == "Octave:single-quote-string") | |
1097 { | |
1098 id.resize (dim_vector (1, n+1)); | |
1099 st.resize (dim_vector (1, n+1)); | |
7202 | 1100 |
7206 | 1101 id(n) = tid(i); |
1102 st(n) = tst(i); | |
1103 | |
1104 n++; | |
1105 } | |
7202 | 1106 } |
1107 } | |
1108 } | |
1109 | |
1110 tmp.assign ("identifier", id); | |
1111 tmp.assign ("state", st); | |
5567 | 1112 |
1113 warning_options = tmp; | |
1114 | |
3935 | 1115 done = true; |
1116 } | |
5567 | 1117 else if (arg2 == "backtrace") |
1118 { | |
1119 if (arg1 != "error") | |
1120 { | |
1121 Vbacktrace_on_warning = (arg1 == "on"); | |
1122 done = true; | |
1123 } | |
1124 } | |
1125 else if (arg2 == "debug") | |
1126 { | |
1127 if (arg1 != "error") | |
1128 { | |
5794 | 1129 Vdebug_on_warning = (arg1 == "on"); |
5567 | 1130 done = true; |
1131 } | |
1132 } | |
1133 else if (arg2 == "verbose") | |
1134 { | |
1135 if (arg1 != "error") | |
1136 { | |
1137 Vverbose_warning = (arg1 == "on"); | |
1138 done = true; | |
1139 } | |
1140 } | |
5582 | 1141 else if (arg2 == "quiet") |
1142 { | |
1143 if (arg1 != "error") | |
1144 { | |
1145 Vquiet_warning = (arg1 == "on"); | |
1146 done = true; | |
1147 } | |
1148 } | |
5567 | 1149 else |
3935 | 1150 { |
5567 | 1151 if (arg2 == "last") |
1152 arg2 = Vlast_warning_id; | |
1153 | |
1154 if (arg2 == "all") | |
5794 | 1155 initialize_warning_options (arg1); |
5567 | 1156 else |
1157 { | |
1158 Cell ident = warning_options.contents ("identifier"); | |
1159 Cell state = warning_options.contents ("state"); | |
1160 | |
1161 octave_idx_type nel = ident.numel (); | |
1162 | |
1163 bool found = false; | |
1164 | |
1165 for (octave_idx_type i = 0; i < nel; i++) | |
1166 { | |
1167 if (ident(i).string_value () == arg2) | |
1168 { | |
5775 | 1169 // FIXME -- if state for "all" is |
5567 | 1170 // same as arg1, we can simply remove the |
1171 // item from the list. | |
1172 | |
1173 state(i) = arg1; | |
1174 warning_options.assign ("state", state); | |
1175 found = true; | |
1176 break; | |
1177 } | |
1178 } | |
1179 | |
1180 if (! found) | |
1181 { | |
5775 | 1182 // FIXME -- if state for "all" is |
5567 | 1183 // same as arg1, we don't need to do anything. |
1184 | |
1185 ident.resize (dim_vector (1, nel+1)); | |
1186 state.resize (dim_vector (1, nel+1)); | |
1187 | |
1188 ident(nel) = arg2; | |
1189 state(nel) = arg1; | |
1190 | |
1191 warning_options.clear (); | |
1192 | |
1193 warning_options.assign ("identifier", ident); | |
1194 warning_options.assign ("state", state); | |
1195 } | |
1196 } | |
1197 | |
3935 | 1198 done = true; |
1199 } | |
5567 | 1200 |
1201 if (done && nargout > 0) | |
6427 | 1202 retval = old_warning_options; |
5567 | 1203 } |
1204 else if (arg1 == "query") | |
1205 { | |
1206 if (arg2 == "all") | |
1207 retval = warning_options; | |
1208 else if (arg2 == "backtrace" || arg2 == "debug" | |
5582 | 1209 || arg2 == "verbose" || arg2 == "quiet") |
5567 | 1210 { |
1211 Octave_map tmp; | |
1212 tmp.assign ("identifier", arg2); | |
1213 if (arg2 == "backtrace") | |
1214 tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off"); | |
1215 else if (arg2 == "debug") | |
1216 tmp.assign ("state", Vdebug_on_warning ? "on" : "off"); | |
5582 | 1217 else if (arg2 == "verbose") |
1218 tmp.assign ("state", Vverbose_warning ? "on" : "off"); | |
5567 | 1219 else |
5582 | 1220 tmp.assign ("state", Vquiet_warning ? "on" : "off"); |
1221 | |
1222 retval = tmp; | |
5567 | 1223 } |
1224 else | |
3935 | 1225 { |
5567 | 1226 if (arg2 == "last") |
1227 arg2 = Vlast_warning_id; | |
1228 | |
1229 Cell ident = warning_options.contents ("identifier"); | |
1230 Cell state = warning_options.contents ("state"); | |
1231 | |
1232 octave_idx_type nel = ident.numel (); | |
1233 | |
1234 bool found = false; | |
1235 | |
1236 std::string val; | |
1237 | |
1238 for (octave_idx_type i = 0; i < nel; i++) | |
1239 { | |
1240 if (ident(i).string_value () == arg2) | |
1241 { | |
1242 val = state(i).string_value (); | |
1243 found = true; | |
1244 break; | |
1245 } | |
1246 } | |
1247 | |
5781 | 1248 if (! found) |
1249 { | |
1250 for (octave_idx_type i = 0; i < nel; i++) | |
1251 { | |
1252 if (ident(i).string_value () == "all") | |
1253 { | |
1254 val = state(i).string_value (); | |
1255 found = true; | |
1256 break; | |
1257 } | |
1258 } | |
1259 } | |
1260 | |
5567 | 1261 if (found) |
1262 { | |
1263 Octave_map tmp; | |
1264 | |
1265 tmp.assign ("identifier", arg2); | |
1266 tmp.assign ("state", val); | |
1267 | |
1268 retval = tmp; | |
1269 } | |
1270 else | |
5781 | 1271 error ("warning: unable to find default warning state!"); |
3935 | 1272 } |
5567 | 1273 |
1274 done = true; | |
3935 | 1275 } |
3934 | 1276 } |
1277 } | |
5567 | 1278 else if (argc == 1) |
1279 { | |
1280 retval = warning_options; | |
3934 | 1281 |
5567 | 1282 done = true; |
1283 } | |
1284 else if (argc == 2) | |
1285 { | |
1286 octave_value arg = args(0); | |
1287 | |
1288 Octave_map old_warning_options = warning_options; | |
1289 | |
1290 if (arg.is_map ()) | |
1291 { | |
1292 Octave_map m = arg.map_value (); | |
1293 | |
1294 if (m.contains ("identifier") && m.contains ("state")) | |
6427 | 1295 warning_options = m; |
5567 | 1296 else |
1297 error ("warning: expecting structure with fields `identifier' and `state'"); | |
1298 | |
1299 done = true; | |
1300 | |
1301 if (nargout > 0) | |
1302 retval = old_warning_options; | |
1303 } | |
1304 } | |
1305 | |
1306 if (! (error_state || done)) | |
3935 | 1307 { |
5567 | 1308 octave_value_list nargs = args; |
1309 | |
1310 std::string id; | |
1311 | |
1312 if (nargin > 1) | |
1313 { | |
1314 std::string arg1 = args(0).string_value (); | |
1315 | |
1316 if (! error_state) | |
1317 { | |
8021 | 1318 if (arg1.find ('%') == std::string::npos) |
5567 | 1319 { |
1320 id = arg1; | |
1321 | |
1322 nargs.resize (nargin-1); | |
1323 | |
1324 for (int i = 1; i < nargin; i++) | |
1325 nargs(i-1) = args(i); | |
1326 } | |
1327 } | |
1328 else | |
1329 return retval; | |
1330 } | |
1331 | |
3935 | 1332 std::string prev_msg = Vlast_warning_message; |
1333 | |
5567 | 1334 std::string curr_msg = handle_message (warning_with_id, id.c_str (), |
1335 "unspecified warning", nargs); | |
3935 | 1336 |
1337 if (nargout > 0) | |
5567 | 1338 retval = prev_msg; |
3935 | 1339 } |
1340 | |
3934 | 1341 return retval; |
1342 } | |
1343 | |
5904 | 1344 void |
5794 | 1345 disable_warning (const std::string& id) |
1346 { | |
1347 octave_value_list args; | |
1348 | |
1349 args(1) = id; | |
1350 args(0) = "off"; | |
1351 | |
1352 Fwarning (args, 0); | |
1353 } | |
1354 | |
1355 void | |
1356 initialize_default_warning_state (void) | |
1357 { | |
1358 initialize_warning_options ("on"); | |
1359 | |
1360 // Most people will want to have the following disabled. | |
1361 | |
1362 disable_warning ("Octave:array-to-scalar"); | |
1363 disable_warning ("Octave:array-to-vector"); | |
1364 disable_warning ("Octave:empty-list-elements"); | |
1365 disable_warning ("Octave:fortran-indexing"); | |
1366 disable_warning ("Octave:imag-to-real"); | |
1367 disable_warning ("Octave:matlab-incompatible"); | |
1368 disable_warning ("Octave:missing-semicolon"); | |
1369 disable_warning ("Octave:neg-dim-as-zero"); | |
1370 disable_warning ("Octave:resize-on-range-error"); | |
1371 disable_warning ("Octave:separator-insert"); | |
1372 disable_warning ("Octave:single-quote-string"); | |
1373 disable_warning ("Octave:str-to-num"); | |
1374 disable_warning ("Octave:string-concat"); | |
1375 disable_warning ("Octave:variable-switch-label"); | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1376 disable_warning ("Octave:int-convert-nan"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1377 disable_warning ("Octave:int-convert-non-int-val"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1378 disable_warning ("Octave:int-convert-overflow"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1379 disable_warning ("Octave:int-math-overflow"); |
5794 | 1380 } |
1381 | |
6361 | 1382 DEFUN (lasterror, args, , |
1383 "-*- texinfo -*-\n\ | |
1384 @deftypefn {Built-in Function} {@var{err} =} lasterror (@var{err})\n\ | |
1385 @deftypefnx {Built-in Function} {} lasterror ('reset')\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1386 Returns or sets the last error message. Called without any arguments\n\ |
6361 | 1387 returns a structure containing the last error message, as well as other\n\ |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1388 information related to this error. The elements of this structure are:\n\ |
6361 | 1389 \n\ |
1390 @table @asis\n\ | |
1391 @item 'message'\n\ | |
1392 The text of the last error message\n\ | |
1393 @item 'identifier'\n\ | |
1394 The message identifier of this error message\n\ | |
1395 @item 'stack'\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1396 A structure containing information on where the message occurred. This might\n\ |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8333
diff
changeset
|
1397 be an empty structure if this in the case where this information cannot\n\ |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1398 be obtained. The fields of this structure are:\n\ |
6361 | 1399 \n\ |
1400 @table @asis\n\ | |
1401 @item 'file'\n\ | |
1402 The name of the file where the error occurred\n\ | |
1403 @item 'name'\n\ | |
7001 | 1404 The name of function in which the error occurred\n\ |
6361 | 1405 @item 'line'\n\ |
7001 | 1406 The line number at which the error occurred\n\ |
6361 | 1407 @item 'column'\n\ |
1408 An optional field with the column number at which the error occurred\n\ | |
1409 @end table\n\ | |
1410 @end table\n\ | |
1411 \n\ | |
1412 The @var{err} structure may also be passed to @code{lasterror} to set the\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1413 information about the last error. The only constraint on @var{err} in that\n\ |
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1414 case is that it is a scalar structure. Any fields of @var{err} that match\n\ |
6361 | 1415 the above are set to the value passed in @var{err}, while other fields are\n\ |
1416 set to their default values.\n\ | |
1417 \n\ | |
1418 If @code{lasterror} is called with the argument 'reset', all values take\n\ | |
1419 their default values.\n\ | |
1420 @end deftypefn") | |
1421 { | |
1422 octave_value retval; | |
1423 int nargin = args.length(); | |
1424 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1425 unwind_protect::begin_frame ("Flasterror"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1426 |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1427 unwind_protect_int (error_state); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1428 error_state = 0; |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1429 |
6361 | 1430 if (nargin < 2) |
1431 { | |
1432 Octave_map err; | |
1433 | |
1434 err.assign ("message", Vlast_error_message); | |
1435 err.assign ("identifier", Vlast_error_id); | |
1436 | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1437 err.assign ("stack", octave_value (Vlast_error_stack)); |
6361 | 1438 |
1439 if (nargin == 1) | |
1440 { | |
1441 if (args(0).is_string()) | |
1442 { | |
6483 | 1443 if (args(0).string_value () == "reset") |
6361 | 1444 { |
1445 Vlast_error_message = std::string(); | |
1446 Vlast_error_id = std::string(); | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1447 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1448 Vlast_error_stack = initialize_last_error_stack (); |
6361 | 1449 } |
1450 else | |
1451 error("lasterror: unrecognized string argument"); | |
1452 } | |
1453 else if (args(0).is_map ()) | |
1454 { | |
6483 | 1455 Octave_map new_err = args(0).map_value (); |
6361 | 1456 std::string new_error_message; |
1457 std::string new_error_id; | |
1458 std::string new_error_file; | |
1459 std::string new_error_name; | |
1460 int new_error_line = -1; | |
1461 int new_error_column = -1; | |
1462 | |
6483 | 1463 if (! error_state && new_err.contains ("message")) |
6361 | 1464 { |
1465 const std::string tmp = | |
6483 | 1466 new_err.contents("message")(0).string_value (); |
6361 | 1467 new_error_message = tmp; |
1468 } | |
1469 | |
6483 | 1470 if (! error_state && new_err.contains ("identifier")) |
6361 | 1471 { |
1472 const std::string tmp = | |
6483 | 1473 new_err.contents("identifier")(0).string_value (); |
6361 | 1474 new_error_id = tmp; |
1475 } | |
1476 | |
6483 | 1477 if (! error_state && new_err.contains ("stack")) |
6361 | 1478 { |
1479 Octave_map new_err_stack = | |
6483 | 1480 new_err.contents("identifier")(0).map_value (); |
6361 | 1481 |
6483 | 1482 if (! error_state && new_err_stack.contains ("file")) |
6361 | 1483 { |
1484 const std::string tmp = | |
6483 | 1485 new_err_stack.contents("file")(0).string_value (); |
6361 | 1486 new_error_file = tmp; |
1487 } | |
1488 | |
6483 | 1489 if (! error_state && new_err_stack.contains ("name")) |
6361 | 1490 { |
1491 const std::string tmp = | |
6483 | 1492 new_err_stack.contents("name")(0).string_value (); |
6361 | 1493 new_error_name = tmp; |
1494 } | |
1495 | |
6483 | 1496 if (! error_state && new_err_stack.contains ("line")) |
6361 | 1497 { |
1498 const int tmp = | |
6483 | 1499 new_err_stack.contents("line")(0).nint_value (); |
6361 | 1500 new_error_line = tmp; |
1501 } | |
1502 | |
6483 | 1503 if (! error_state && new_err_stack.contains ("column")) |
6361 | 1504 { |
1505 const int tmp = | |
6483 | 1506 new_err_stack.contents("column")(0).nint_value (); |
6361 | 1507 new_error_column = tmp; |
1508 } | |
1509 } | |
1510 | |
1511 if (! error_state) | |
1512 { | |
1513 Vlast_error_message = new_error_message; | |
1514 Vlast_error_id = new_error_id; | |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1515 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1516 octave_idx_type curr_frame = -1; |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1517 |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1518 Vlast_error_stack |
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1519 = octave_call_stack::backtrace (0, curr_frame); |
6361 | 1520 } |
1521 } | |
1522 else | |
1523 error ("lasterror: argument must be a structure or a string"); | |
1524 } | |
1525 | |
6483 | 1526 if (! error_state) |
6361 | 1527 retval = err; |
1528 } | |
1529 else | |
1530 print_usage (); | |
1531 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1532 unwind_protect::run_frame ("Flasterror"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1533 |
6361 | 1534 return retval; |
1535 } | |
1536 | |
5567 | 1537 DEFUN (lasterr, args, nargout, |
3935 | 1538 "-*- texinfo -*-\n\ |
5567 | 1539 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr (@var{msg}, @var{msgid})\n\ |
3935 | 1540 Without any arguments, return the last error message. With one\n\ |
5567 | 1541 argument, set the last error message to @var{msg}. With two arguments,\n\ |
1542 also set the last message identifier.\n\ | |
3935 | 1543 @end deftypefn") |
1544 { | |
1545 octave_value_list retval; | |
1546 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1547 unwind_protect::begin_frame ("Flasterr"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1548 |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1549 unwind_protect_int (error_state); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1550 error_state = 0; |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1551 |
3935 | 1552 int argc = args.length () + 1; |
1553 | |
5567 | 1554 if (argc < 4) |
5335 | 1555 { |
1556 string_vector argv = args.make_argv ("lasterr"); | |
3935 | 1557 |
5335 | 1558 if (! error_state) |
1559 { | |
5567 | 1560 std::string prev_error_id = Vlast_error_id; |
1561 std::string prev_error_message = Vlast_error_message; | |
1562 | |
1563 if (argc > 2) | |
1564 Vlast_error_id = argv(2); | |
1565 | |
1566 if (argc > 1) | |
5335 | 1567 Vlast_error_message = argv(1); |
5567 | 1568 |
1569 if (argc == 1 || nargout > 0) | |
1570 { | |
1571 retval(1) = prev_error_id; | |
1572 retval(0) = prev_error_message; | |
1573 } | |
5335 | 1574 } |
5567 | 1575 else |
5582 | 1576 error ("lasterr: expecting arguments to be character strings"); |
5335 | 1577 } |
3935 | 1578 else |
5823 | 1579 print_usage (); |
3935 | 1580 |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1581 unwind_protect::run_frame ("Flasterr"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1582 |
3935 | 1583 return retval; |
1584 } | |
1585 | |
4699 | 1586 // For backward compatibility. |
1587 DEFALIAS (error_text, lasterr); | |
1588 DEFALIAS (__error_text__, lasterr); | |
1589 | |
5567 | 1590 DEFUN (lastwarn, args, nargout, |
3934 | 1591 "-*- texinfo -*-\n\ |
5567 | 1592 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn (@var{msg}, @var{msgid})\n\ |
3935 | 1593 Without any arguments, return the last warning message. With one\n\ |
5567 | 1594 argument, set the last warning message to @var{msg}. With two arguments,\n\ |
1595 also set the last message identifier.\n\ | |
3934 | 1596 @end deftypefn") |
1597 { | |
1598 octave_value_list retval; | |
1599 | |
1600 int argc = args.length () + 1; | |
1601 | |
5567 | 1602 if (argc < 4) |
1603 { | |
1604 string_vector argv = args.make_argv ("lastwarn"); | |
1605 | |
1606 if (! error_state) | |
1607 { | |
1608 std::string prev_warning_id = Vlast_warning_id; | |
1609 std::string prev_warning_message = Vlast_warning_message; | |
1610 | |
1611 if (argc > 2) | |
1612 Vlast_warning_id = argv(2); | |
3934 | 1613 |
5567 | 1614 if (argc > 1) |
1615 Vlast_warning_message = argv(1); | |
1616 | |
1617 if (argc == 1 || nargout > 0) | |
1618 { | |
5582 | 1619 warning_state = 0; |
5567 | 1620 retval(1) = prev_warning_id; |
1621 retval(0) = prev_warning_message; | |
1622 } | |
1623 } | |
1624 else | |
1625 error ("lastwarn: expecting arguments to be character strings"); | |
1626 } | |
3934 | 1627 else |
5823 | 1628 print_usage (); |
3934 | 1629 |
1630 return retval; | |
897 | 1631 } |
1632 | |
1957 | 1633 DEFUN (usage, args, , |
3373 | 1634 "-*- texinfo -*-\n\ |
1635 @deftypefn {Built-in Function} {} usage (@var{msg})\n\ | |
1636 Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\ | |
1637 set Octave's internal error state such that control will return to the\n\ | |
1638 top level without evaluating any more commands. This is useful for\n\ | |
1639 aborting from functions.\n\ | |
1640 \n\ | |
1641 After @code{usage} is evaluated, Octave will print a traceback of all\n\ | |
1642 the function calls leading to the usage message.\n\ | |
899 | 1643 \n\ |
3373 | 1644 You should use this function for reporting problems errors that result\n\ |
1645 from an improper call to a function, such as calling a function with an\n\ | |
1646 incorrect number of arguments, or with arguments of the wrong type. For\n\ | |
1647 example, most functions distributed with Octave begin with code like\n\ | |
1648 this\n\ | |
1649 \n\ | |
1650 @example\n\ | |
1651 @group\n\ | |
1652 if (nargin != 2)\n\ | |
1653 usage (\"foo (a, b)\");\n\ | |
1654 endif\n\ | |
1655 @end group\n\ | |
1656 @end example\n\ | |
1657 \n\ | |
1658 @noindent\n\ | |
1659 to check for the proper number of arguments.\n\ | |
1660 @end deftypefn") | |
899 | 1661 { |
3934 | 1662 octave_value_list retval; |
5567 | 1663 handle_message (usage_with_id, "", "unknown", args); |
3934 | 1664 return retval; |
899 | 1665 } |
1666 | |
5794 | 1667 DEFUN (beep_on_error, args, nargout, |
1668 "-*- texinfo -*-\n\ | |
1669 @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\ | |
1670 @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\ | |
1671 Query or set the internal variable that controls whether Octave will try\n\ | |
1672 to ring the terminal bell before printing an error message.\n\ | |
1673 @end deftypefn") | |
3707 | 1674 { |
5794 | 1675 return SET_INTERNAL_VARIABLE (beep_on_error); |
3707 | 1676 } |
1677 | |
5794 | 1678 DEFUN (debug_on_error, args, nargout, |
3373 | 1679 "-*- texinfo -*-\n\ |
5794 | 1680 @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\ |
1681 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\ | |
1682 Query or set the internal variable that controls whether Octave will try\n\ | |
3707 | 1683 to enter the debugger when an error is encountered. This will also\n\ |
1684 inhibit printing of the normal traceback message (you will only see\n\ | |
5794 | 1685 the top-level error message).\n\ |
1686 @end deftypefn") | |
1687 { | |
1688 return SET_INTERNAL_VARIABLE (debug_on_error); | |
1689 } | |
3707 | 1690 |
5794 | 1691 DEFUN (debug_on_warning, args, nargout, |
3707 | 1692 "-*- texinfo -*-\n\ |
5794 | 1693 @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\ |
1694 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\ | |
1695 Query or set the internal variable that controls whether Octave will try\n\ | |
1696 to enter the debugger when a warning is encountered.\n\ | |
1697 @end deftypefn") | |
1698 { | |
1699 return SET_INTERNAL_VARIABLE (debug_on_warning); | |
2174 | 1700 } |
1701 | |
7977
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1702 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1703 last_error_message (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1704 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1705 return Vlast_error_message; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1706 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1707 |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1708 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1709 last_error_id (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1710 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1711 return Vlast_error_id; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1712 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1713 |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1714 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1715 last_warning_message (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1716 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1717 return Vlast_warning_message; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1718 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1719 |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1720 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1721 last_warning_id (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1722 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1723 return Vlast_warning_id; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1724 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1725 |
1 | 1726 /* |
1727 ;;; Local Variables: *** | |
1728 ;;; mode: C++ *** | |
1729 ;;; End: *** | |
1730 */ |