GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
errwarn.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2016-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "defun.h"
31 #include "error.h"
32 #include "errwarn.h"
33 #include "ovl.h"
34 #include "utils.h"
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 // Alphabetized list of common errors and warnings.
38 ////////////////////////////////////////////////////////////////////////////////
39 
40 void
42 {
43  error ("plot: can only plot in 2 or 3 dimensions");
44 }
45 
46 void
47 err_data_conversion (const char *from, const char *to)
48 {
49  error ("unable to convert from %s to %s format", from, to);
50 }
51 
52 void
53 err_disabled_feature (const std::string& fcn, const std::string& feature,
54  const std::string& pkg /* ="Octave" */)
55 {
56  if (! fcn.empty ())
57  error ("%s: support for %s was unavailable or disabled when %s was built",
58  fcn.c_str (), feature.c_str (), pkg.c_str ());
59  else
60  error ("support for %s was unavailable or disabled when %s was built",
61  feature.c_str (), pkg.c_str ());
62 }
63 
64 void
66 {
67  error ("a cs-list cannot be further indexed");
68 }
69 
70 void
71 err_invalid_conversion (const std::string& from, const std::string& to)
72 {
73  error ("invalid conversion from %s to %s", from.c_str (), to.c_str ());
74 }
75 
76 void
78 {
79  error ("invalid dimension inquiry of a non-existent value");
80 }
81 
82 void
84 {
85  error ("invalid dot name structure assignment because the structure array is empty. Specify a subscript on the structure array to resolve.");
86 }
87 
88 void
90 {
91  error ("invalid assignment to cs-list outside multiple assignment");
92 }
93 
94 void
96 {
97  error ("nonconformant matrices");
98 }
99 
100 void
103 {
104  error ("nonconformant matrices (op1 is %" OCTAVE_IDX_TYPE_FORMAT
105  "x%" OCTAVE_IDX_TYPE_FORMAT ", op2 is %" OCTAVE_IDX_TYPE_FORMAT
106  "x%" OCTAVE_IDX_TYPE_FORMAT ")", r1, c1, r2, c2);
107 }
108 
109 void
110 err_not_implemented (const char *fcn)
111 {
112  error ("%s: not implemented", fcn);
113 }
114 
115 void
117 {
118  error ("range constant used in invalid context");
119 }
120 
121 void
122 err_square_matrix_required (const char *fcn, const char *name)
123 {
124  error ("%s: %s must be a square matrix", fcn, name);
125 }
126 
127 void
129 {
130  error ("std::string constant used in invalid context");
131 }
132 
133 void
135 {
136  error ("%s: unrecognized data format requested", name);
137 }
138 
139 void
141 {
142  error ("unrecognized floating point format requested");
143 }
144 
145 void
147 {
148  error ("%s: user-supplied function returned invalid value", name);
149 }
150 
151 void
153 {
154  octave::execution_exception e;
155 
157 }
158 
159 void
160 err_user_supplied_eval (octave::execution_exception& e, const char *name)
161 {
162  error (e, "%s: evaluation of user-supplied function failed", name);
163 }
164 
165 void
166 err_wrong_type_arg (const char *name, const char *s)
167 {
168  octave::execution_exception e;
169 
170  err_wrong_type_arg (e, name, s);
171 }
172 
173 void
174 err_wrong_type_arg (octave::execution_exception& e,
175  const char *name, const char *s)
176 {
177  error (e, "%s: wrong type argument '%s'", name, s);
178 }
179 
180 void
181 err_wrong_type_arg (const char *name, const std::string& s)
182 {
183  octave::execution_exception e;
184 
185  err_wrong_type_arg (e, name, s.c_str ());
186 }
187 
188 void
189 err_wrong_type_arg (octave::execution_exception& e,
190  const char *name, const std::string& s)
191 {
192  err_wrong_type_arg (e, name, s.c_str ());
193 }
194 
195 void
196 err_wrong_type_arg (const char *name, const octave_value& tc)
197 {
198  octave::execution_exception e;
199 
200  err_wrong_type_arg (e, name, tc);
201 }
202 
203 void
204 err_wrong_type_arg (octave::execution_exception& e,
205  const char *name, const octave_value& tc)
206 {
207  std::string type = tc.type_name ();
208 
210 }
211 
212 void
213 err_wrong_type_arg (const std::string& name, const octave_value& tc)
214 {
215  octave::execution_exception e;
216 
217  err_wrong_type_arg (e, name, tc);
218 }
219 
220 void
221 err_wrong_type_arg (octave::execution_exception& e,
222  const std::string& name, const octave_value& tc)
223 {
224  err_wrong_type_arg (e, name.c_str (), tc);
225 }
226 
227 void
228 err_wrong_type_arg (const char *s)
229 {
230  octave::execution_exception e;
231 
232  err_wrong_type_arg (e, s);
233 }
234 
235 void
236 err_wrong_type_arg (octave::execution_exception& e, const char *s)
237 {
238  error (e, "wrong type argument '%s'", s);
239 }
240 
241 void
242 err_wrong_type_arg (const std::string& s)
243 {
244  octave::execution_exception e;
245 
246  err_wrong_type_arg (e, s);
247 }
248 
249 void
250 err_wrong_type_arg (octave::execution_exception& e, const std::string& s)
251 {
252  err_wrong_type_arg (e, s.c_str ());
253 }
254 
255 void
257 {
258  octave::execution_exception e;
259 
260  err_wrong_type_arg (e, tc);
261 }
262 
263 void
264 err_wrong_type_arg (octave::execution_exception& e, const octave_value& tc)
265 {
266  std::string type = tc.type_name ();
267 
269 }
270 
271 void
273 {
274  std::string type = op.type_name ();
275  error ("invalid operand '%s' for binary operator", type.c_str ());
276 }
277 
278 void
280 {
281  std::string type = op.type_name ();
282  error ("invalid operand '%s' for unary operator", type.c_str ());
283 }
284 
285 void
287 {
288  warning_with_id ("Octave:array-as-logical",
289  "Using an object of size %s as "
290  "a boolean value implies all().",
291  dv.str ().c_str ());
292 }
293 
294 /*
295 %!warning <boolean value implies all>
296 %! warning ("on", "Octave:array-as-logical");
297 %! if ([1 1 0])
298 %! assert (false);
299 %! endif
300 */
301 
302 void
304 {
305  warning_with_id ("Octave:language-extension",
306  "comparing complex numbers is not supported in Matlab");
307 }
308 
309 void
310 warn_data_file_in_path (const std::string& fcn, const std::string& file)
311 {
312  warning_with_id ("Octave:data-file-in-path",
313  "%s: '%s' found by searching load path",
314  fcn.c_str (), file.c_str ());
315 }
316 
317 void
318 warn_disabled_feature (const std::string& fcn, const std::string& feature,
319  const std::string& pkg /*="Octave"*/)
320 {
321  if (! fcn.empty ())
322  warning ("%s: support for %s was unavailable or disabled when %s was built",
323  fcn.c_str (), feature.c_str (), pkg.c_str ());
324  else
325  warning ("support for %s was unavailable or disabled when %s was built",
326  feature.c_str (), pkg.c_str ());
327 }
328 
329 void
330 warn_empty_arg (const char *name)
331 {
332  warning ("%s: argument is empty matrix", name);
333 }
334 
335 void
336 warn_empty_index (const std::string& type_name)
337 {
338  warning_with_id ("Octave:empty-index",
339  "'%s' object indexed with empty index list",
340  type_name.c_str ());
341 }
342 
343 void
344 warn_implicit_conversion (const char *id, const char *from, const char *to)
345 {
346  warning_with_id (id, "implicit conversion from %s to %s", from, to);
347 }
348 
349 void
350 warn_implicit_conversion (const std::string& id,
351  const std::string& from, const std::string& to)
352 {
353  warning_with_id (id.c_str (),
354  "implicit conversion from %s to %s",
355  from.c_str (), to.c_str ());
356 }
357 
358 void
360 {
361  warning ("invalid value specified for '%s'", name);
362 }
363 
364 void
366 {
367  warning_with_id ("Octave:logical-conversion",
368  "value not equal to 1 or 0 converted to logical 1");
369 }
370 
371 void
372 warn_wrong_type_arg (const char *name, const octave_value& tc)
373 {
374  std::string type = tc.type_name ();
375 
376  warning ("%s: wrong type argument '%s'", name, type.c_str ());
377 }
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
std::string str(char sep='x') const
Definition: dim-vector.cc:85
std::string type_name(void) const
Definition: ov.h:1254
void warning(const char *fmt,...)
Definition: error.cc:1050
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1065
void error(const char *fmt,...)
Definition: error.cc:968
void err_unrecognized_data_fmt(const char *name)
Definition: errwarn.cc:134
void err_wrong_type_arg_for_unary_op(const octave_value &op)
Definition: errwarn.cc:279
void err_invalid_inquiry_subscript(void)
Definition: errwarn.cc:77
void err_square_matrix_required(const char *fcn, const char *name)
Definition: errwarn.cc:122
void err_unrecognized_float_fmt(void)
Definition: errwarn.cc:140
void err_data_conversion(const char *from, const char *to)
Definition: errwarn.cc:47
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:53
void warn_empty_index(const std::string &type_name)
Definition: errwarn.cc:336
void warn_wrong_type_arg(const char *name, const octave_value &tc)
Definition: errwarn.cc:372
void err_wrong_type_arg_for_binary_op(const octave_value &op)
Definition: errwarn.cc:272
void err_wrong_type_arg(const char *name, const char *s)
Definition: errwarn.cc:166
void warn_invalid_value_specified(const char *name)
Definition: errwarn.cc:359
void err_2_or_3_dim_plot(void)
Definition: errwarn.cc:41
void err_user_supplied_eval(const char *name)
Definition: errwarn.cc:152
void err_nonconformant(void)
Definition: errwarn.cc:95
void warn_array_as_logical(const dim_vector &dv)
Definition: errwarn.cc:286
void err_invalid_structure_assignment(void)
Definition: errwarn.cc:83
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:71
void err_string_invalid(void)
Definition: errwarn.cc:128
void err_range_invalid(void)
Definition: errwarn.cc:116
void warn_logical_conversion(void)
Definition: errwarn.cc:365
void err_not_implemented(const char *fcn)
Definition: errwarn.cc:110
void err_nonbraced_cs_list_assignment(void)
Definition: errwarn.cc:89
void warn_complex_cmp(void)
Definition: errwarn.cc:303
void err_user_returned_invalid(const char *name)
Definition: errwarn.cc:146
void warn_empty_arg(const char *name)
Definition: errwarn.cc:330
void err_indexed_cs_list(void)
Definition: errwarn.cc:65
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:344
void warn_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:318
void warn_data_file_in_path(const std::string &fcn, const std::string &file)
Definition: errwarn.cc:310
QString name