Mercurial > octave-nkf
annotate libinterp/corefcn/error.h @ 20616:fd0efcdb3718
use new string_value method to handle value extraction errors
* dirfns.cc, file-io.cc, gammainc.cc, help.cc, load-path.cc,
octave-link.cc, qz.cc, regexp.cc, strfns.cc, syscalls.cc, time.cc,
variables.cc: Use new string_value method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 08 Oct 2015 19:00:51 -0400 |
parents | 19755f4fc851 |
children |
rev | line source |
---|---|
1 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18221
diff
changeset
|
3 Copyright (C) 1993-2015 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
383 | 23 #if !defined (octave_error_h) |
24 #define octave_error_h 1 | |
1 | 25 |
6355 | 26 #include <cstdarg> |
3935 | 27 #include <string> |
1489 | 28 |
18221
6ef8b920a7d6
include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents:
17787
diff
changeset
|
29 class octave_map; |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
30 class octave_value_list; |
11029
4ab04ea74b08
make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents:
10605
diff
changeset
|
31 class unwind_protect; |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
32 |
1 | 33 #define panic_impossible() \ |
19895
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
34 panic ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__) |
1 | 35 |
6109 | 36 extern OCTINTERP_API void reset_error_handler (void); |
4318 | 37 |
6109 | 38 extern OCTINTERP_API int warning_enabled (const std::string& id); |
5781 | 39 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 extern OCTINTERP_API void |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 vmessage (const char *name, const char *fmt, va_list args); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 |
6109 | 43 extern OCTINTERP_API void message (const char *name, const char *fmt, ...); |
6338 | 44 |
45 extern OCTINTERP_API void vusage (const char *fmt, va_list args); | |
6109 | 46 extern OCTINTERP_API void usage (const char *fmt, ...); |
6338 | 47 |
48 extern OCTINTERP_API void vwarning (const char *fmt, va_list args); | |
6109 | 49 extern OCTINTERP_API void warning (const char *fmt, ...); |
6338 | 50 |
51 extern OCTINTERP_API void verror (const char *fmt, va_list args); | |
6109 | 52 extern OCTINTERP_API void error (const char *fmt, ...); |
6338 | 53 |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
54 extern OCTINTERP_API void verror_with_cfn (const char *fmt, va_list args); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
55 extern OCTINTERP_API void error_with_cfn (const char *fmt, ...); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
56 |
6338 | 57 extern OCTINTERP_API void vparse_error (const char *fmt, va_list args); |
6109 | 58 extern OCTINTERP_API void parse_error (const char *fmt, ...); |
5567 | 59 |
6109 | 60 extern OCTINTERP_API void |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
61 vmessage_with_id (const char *id, const char *name, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
62 const char *fmt, va_list args); |
6338 | 63 |
64 extern OCTINTERP_API void | |
5567 | 65 message_with_id (const char *id, const char *name, const char *fmt, ...); |
66 | |
6109 | 67 extern OCTINTERP_API void |
6338 | 68 vusage_with_id (const char *id, const char *fmt, va_list args); |
69 | |
70 extern OCTINTERP_API void | |
5567 | 71 usage_with_id (const char *id, const char *fmt, ...); |
72 | |
6109 | 73 extern OCTINTERP_API void |
6338 | 74 vwarning_with_id (const char *id, const char *fmt, va_list args); |
75 | |
76 extern OCTINTERP_API void | |
5567 | 77 warning_with_id (const char *id, const char *fmt, ...); |
78 | |
6109 | 79 extern OCTINTERP_API void |
6338 | 80 verror_with_id (const char *id, const char *fmt, va_list args); |
81 | |
82 extern OCTINTERP_API void | |
5567 | 83 error_with_id (const char *id, const char *fmt, ...); |
84 | |
6109 | 85 extern OCTINTERP_API void |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
86 verror_with_id_cfn (const char *id, const char *fmt, va_list args); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
87 |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
88 extern OCTINTERP_API void |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
89 error_with_id_cfn (const char *id, const char *fmt, ...); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
90 |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
7977
diff
changeset
|
91 extern OCTINTERP_API void |
6338 | 92 vparse_error_with_id (const char *id, const char *fmt, va_list args); |
93 | |
94 extern OCTINTERP_API void | |
5567 | 95 parse_error_with_id (const char *id, const char *fmt, ...); |
96 | |
6109 | 97 extern OCTINTERP_API void panic (const char *fmt, ...) GCC_ATTR_NORETURN; |
1 | 98 |
4732 | 99 // Helper function for print_usage defined in defun.cc. |
6109 | 100 extern OCTINTERP_API void defun_usage_message (const std::string& msg); |
4732 | 101 |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
102 extern OCTINTERP_API octave_value_list |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
103 set_warning_state (const std::string& id, const std::string& state); |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
104 |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
105 extern OCTINTERP_API octave_value_list |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
106 set_warning_state (const octave_value_list& args); |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10313
diff
changeset
|
107 |
6109 | 108 extern OCTINTERP_API void disable_warning (const std::string& id); |
109 extern OCTINTERP_API void initialize_default_warning_state (void); | |
5794 | 110 |
7353 | 111 // TRUE means that Octave will try to enter the debugger when an error |
112 // is encountered. This will also inhibit printing of the normal | |
113 // traceback message (you will only see the top-level error message). | |
114 extern OCTINTERP_API bool Vdebug_on_error; | |
115 | |
116 // TRUE means that Octave will try to enter the debugger when a warning | |
117 // is encountered. | |
118 extern OCTINTERP_API bool Vdebug_on_warning; | |
119 | |
143 | 120 // Current error state. |
6109 | 121 extern OCTINTERP_API int error_state; |
143 | 122 |
3489 | 123 // Current warning state. |
6109 | 124 extern OCTINTERP_API int warning_state; |
3489 | 125 |
1489 | 126 // Tell the error handler whether to print messages, or just store |
127 // them for later. Used for handling errors in eval() and | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
128 // the 'unwind_protect' statement. |
6109 | 129 extern OCTINTERP_API int buffer_error_messages; |
1489 | 130 |
3815 | 131 // TRUE means error messages are turned off. |
6109 | 132 extern OCTINTERP_API bool discard_error_messages; |
3815 | 133 |
4452 | 134 // TRUE means warning messages are turned off. |
6109 | 135 extern OCTINTERP_API bool discard_warning_messages; |
4452 | 136 |
7977
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7353
diff
changeset
|
137 // Helper functions to pass last error and warning messages and ids |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7353
diff
changeset
|
138 extern OCTINTERP_API std::string 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:
7353
diff
changeset
|
139 extern OCTINTERP_API std::string last_error_id (void); |
18221
6ef8b920a7d6
include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents:
17787
diff
changeset
|
140 extern OCTINTERP_API octave_map last_error_stack (void); |
7977
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7353
diff
changeset
|
141 extern OCTINTERP_API std::string 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:
7353
diff
changeset
|
142 extern OCTINTERP_API std::string 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:
7353
diff
changeset
|
143 |
11029
4ab04ea74b08
make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents:
10605
diff
changeset
|
144 extern OCTINTERP_API void interpreter_try (unwind_protect&); |
4ab04ea74b08
make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents:
10605
diff
changeset
|
145 |
1 | 146 #endif |