GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
error.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2018 John W. Eaton
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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_error_h)
24 #define octave_error_h 1
25 
26 #include "octave-config.h"
27 
28 #include <cstdarg>
29 #include <string>
30 
31 #include "unwind-prot.h"
32 
33 class octave_map;
34 class octave_value_list;
35 namespace octave
36 {
37  class execution_exception;
38 }
39 
40 #define panic_impossible() \
41  panic ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__)
42 
43 extern OCTINTERP_API void reset_error_handler (void);
44 
45 extern OCTINTERP_API int warning_enabled (const std::string& id);
46 
47 extern OCTINTERP_API octave::execution_exception
48 make_execution_exception (const char *who);
49 
50 extern OCTINTERP_API void
51 vmessage (const char *name, const char *fmt, va_list args);
52 
53 extern OCTINTERP_API void message (const char *name, const char *fmt, ...);
54 
55 OCTAVE_DEPRECATED (4.2, "use 'print_usage' or 'verror' instead")
56 OCTAVE_NORETURN OCTINTERP_API extern
57 void vusage (const char *fmt, va_list args);
58 
59 OCTAVE_DEPRECATED (4.2, "use 'print_usage' or 'error' instead")
60 OCTAVE_NORETURN OCTINTERP_API extern
61 void usage (const char *fmt, ...);
62 
63 extern OCTINTERP_API void vwarning (const char *fmt, va_list args);
64 extern OCTINTERP_API void warning (const char *fmt, ...);
65 
66 OCTAVE_NORETURN OCTINTERP_API extern
67 void verror (const char *fmt, va_list args);
68 
69 OCTAVE_NORETURN OCTINTERP_API extern
70 void error (const char *fmt, ...);
71 
72 OCTAVE_NORETURN OCTINTERP_API extern
73 void verror (octave::execution_exception&, const char *fmt, va_list args);
74 OCTAVE_NORETURN OCTINTERP_API extern
75 void error (octave::execution_exception&, const char *fmt, ...);
76 
77 OCTAVE_NORETURN OCTINTERP_API extern
78 void verror_with_cfn (const char *fmt, va_list args);
79 OCTAVE_NORETURN OCTINTERP_API extern
80 void error_with_cfn (const char *fmt, ...);
81 
82 OCTAVE_NORETURN OCTINTERP_API extern
83 void vparse_error (const char *fmt, va_list args);
84 OCTAVE_NORETURN OCTINTERP_API extern
85 void parse_error (const char *fmt, ...);
86 
87 extern OCTINTERP_API void
88 vmessage_with_id (const char *id, const char *name,
89  const char *fmt, va_list args);
90 
91 extern OCTINTERP_API void
92 message_with_id (const char *id, const char *name, const char *fmt, ...);
93 
94 OCTAVE_NORETURN OCTINTERP_API extern
95 void vusage_with_id (const char *id, const char *fmt, va_list args);
96 
97 OCTAVE_NORETURN OCTINTERP_API extern
98 void usage_with_id (const char *id, const char *fmt, ...);
99 
100 extern OCTINTERP_API void
101 vwarning_with_id (const char *id, const char *fmt, va_list args);
102 
103 extern OCTINTERP_API void
104 warning_with_id (const char *id, const char *fmt, ...);
105 
106 OCTAVE_NORETURN OCTINTERP_API extern
107 void verror_with_id (const char *id, const char *fmt, va_list args);
108 
109 OCTAVE_NORETURN OCTINTERP_API extern
110 void error_with_id (const char *id, const char *fmt, ...);
111 
112 OCTAVE_NORETURN OCTINTERP_API extern
113 void verror_with_id_cfn (const char *id, const char *fmt, va_list args);
114 
115 OCTAVE_NORETURN OCTINTERP_API extern
116 void error_with_id_cfn (const char *id, const char *fmt, ...);
117 
118 OCTAVE_NORETURN OCTINTERP_API extern
119 void vparse_error_with_id (const char *id, const char *fmt, va_list args);
120 
121 OCTAVE_NORETURN OCTINTERP_API extern
122 void parse_error_with_id (const char *id, const char *fmt, ...);
123 
124 OCTAVE_NORETURN OCTINTERP_API extern
125 void panic (const char *fmt, ...);
126 
127 // Helper function for print_usage defined in defun.cc.
128 extern OCTINTERP_API void defun_usage_message (const std::string& msg);
129 
130 extern OCTINTERP_API octave_value_list
131 set_warning_state (const std::string& id, const std::string& state);
132 
133 extern OCTINTERP_API octave_value_list
135 
136 extern OCTINTERP_API void disable_warning (const std::string& id);
137 extern OCTINTERP_API void initialize_default_warning_state (void);
138 
139 // TRUE means that Octave will try to enter the debugger when an error
140 // is encountered. This will also inhibit printing of the normal
141 // traceback message (you will only see the top-level error message).
142 extern OCTINTERP_API bool Vdebug_on_error;
143 
144 // TRUE means that Octave will try to enter the debugger when an error
145 // is encountered within the 'try' section of a 'try' / 'catch' block.
146 extern OCTINTERP_API bool Vdebug_on_caught;
147 
148 // TRUE means that Octave will try to enter the debugger when a warning
149 // is encountered.
150 extern OCTINTERP_API bool Vdebug_on_warning;
151 
152 // Current error state.
153 extern OCTINTERP_API int error_state;
154 
155 // Current warning state.
156 extern OCTINTERP_API int warning_state;
157 
158 // Tell the error handler whether to print messages, or just store
159 // them for later. Used for handling errors in eval() and
160 // the 'unwind_protect' statement.
161 extern OCTINTERP_API int buffer_error_messages;
162 
163 // The number of layers of try / catch blocks we're in. Used to print
164 // "caught error" instead of "error" when "dbstop if caught error" is on.
165 extern OCTINTERP_API int in_try_catch;
166 
167 // TRUE means error messages are turned off.
168 extern OCTINTERP_API bool discard_error_messages;
169 
170 // TRUE means warning messages are turned off.
171 extern OCTINTERP_API bool discard_warning_messages;
172 
173 // Helper functions to pass last error and warning messages and ids
174 extern OCTINTERP_API std::string last_error_message (void);
175 extern OCTINTERP_API std::string last_error_id (void);
176 extern OCTINTERP_API octave_map last_error_stack (void);
177 extern OCTINTERP_API std::string last_warning_message (void);
178 extern OCTINTERP_API std::string last_warning_id (void);
179 
180 extern OCTINTERP_API void interpreter_try (octave::unwind_protect&);
181 
182 #endif
OCTINTERP_API void vmessage_with_id(const char *id, const char *name, const char *fmt, va_list args)
Definition: error.cc:444
OCTINTERP_API bool Vdebug_on_caught
Definition: error.cc:66
OCTINTERP_API void initialize_default_warning_state(void)
OCTINTERP_API void print_usage(void)
Definition: defun.cc:54
OCTAVE_NORETURN OCTINTERP_API void error_with_id_cfn(const char *id, const char *fmt,...)
Definition: error.cc:638
OCTINTERP_API octave::execution_exception make_execution_exception(const char *who)
Definition: error.cc:341
OCTAVE_NORETURN OCTINTERP_API void vparse_error(const char *fmt, va_list args)
Definition: error.cc:825
OCTINTERP_API void reset_error_handler(void)
Definition: error.cc:125
OCTAVE_NORETURN OCTINTERP_API void panic(const char *fmt,...)
Definition: error.cc:944
OCTINTERP_API void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:816
OCTINTERP_API int in_try_catch
Definition: error.cc:116
OCTINTERP_API octave_value_list set_warning_state(const std::string &id, const std::string &state)
STL namespace.
OCTINTERP_API void message(const char *name, const char *fmt,...)
Definition: error.cc:435
OCTAVE_NORETURN OCTINTERP_API void error_with_id(const char *id, const char *fmt,...)
Definition: error.cc:623
OCTINTERP_API void vmessage(const char *name, const char *fmt, va_list args)
Definition: error.cc:429
OCTINTERP_API void message_with_id(const char *id, const char *name, const char *fmt,...)
Definition: error.cc:451
OCTAVE_EXPORT octave_value_list or class The return code an ordinary file in Octave s or(after appending @samp{.m}) a function file in Octave 's ode
Definition: variables.cc:593
OCTAVE_NORETURN OCTINTERP_API void parse_error(const char *fmt,...)
Definition: error.cc:831
OCTAVE_NORETURN OCTINTERP_API void vparse_error_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:840
nd deftypefn *std::string name
Definition: sysdep.cc:647
OCTINTERP_API void disable_warning(const std::string &id)
OCTINTERP_API bool discard_error_messages
Definition: error.cc:119
OCTINTERP_API std::string last_warning_id(void)
OCTAVE_NORETURN OCTINTERP_API void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
Definition: error.cc:632
OCTAVE_NORETURN OCTINTERP_API void verror_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:617
OCTAVE_NORETURN OCTINTERP_API void verror(const char *fmt, va_list args)
Definition: error.cc:572
OCTINTERP_API std::string last_error_id(void)
OCTINTERP_API bool Vdebug_on_warning
Definition: error.cc:70
OCTAVE_NORETURN OCTINTERP_API void usage_with_id(const char *id, const char *fmt,...)
Definition: error.cc:502
OCTINTERP_API int warning_enabled(const std::string &id)
Definition: error.cc:669
static uint32_t state[624]
Definition: randmtzig.cc:183
OCTINTERP_API bool discard_warning_messages
Definition: error.cc:122
OCTINTERP_API std::string last_error_message(void)
OCTINTERP_API int error_state
Definition: error.cc:107
OCTINTERP_API bool Vdebug_on_error
Definition: error.cc:62
OCTINTERP_API octave_map last_error_stack(void)
OCTAVE_NORETURN OCTINTERP_API void vusage(const char *fmt, va_list args)
Definition: error.cc:481
OCTINTERP_API int warning_state
OCTAVE_NORETURN OCTINTERP_API void vusage_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:496
OCTAVE_NORETURN OCTINTERP_API void error(const char *fmt,...)
Definition: error.cc:578
OCTINTERP_API int buffer_error_messages
Definition: error.cc:112
OCTAVE_NORETURN OCTINTERP_API void verror_with_cfn(const char *fmt, va_list args)
Definition: error.cc:602
OCTINTERP_API std::string last_warning_message(void)
OCTINTERP_API void vwarning_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:810
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
OCTINTERP_API void defun_usage_message(const std::string &msg)
Definition: error.cc:965
OCTAVE_NORETURN OCTINTERP_API void error_with_cfn(const char *fmt,...)
Definition: error.cc:608
OCTAVE_NORETURN OCTINTERP_API void usage(const char *fmt,...)
Definition: error.cc:487
OCTINTERP_API void warning(const char *fmt,...)
Definition: error.cc:801
OCTINTERP_API void interpreter_try(octave::unwind_protect &)
OCTAVE_NORETURN OCTINTERP_API void parse_error_with_id(const char *id, const char *fmt,...)
Definition: error.cc:846
OCTINTERP_API void vwarning(const char *fmt, va_list args)
Definition: error.cc:795