GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
errwarn.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2016-2025 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
40void
42{
43 error ("plot: can only plot in 2 or 3 dimensions");
44}
45
46void
47err_data_conversion (const char *from, const char *to)
48{
49 error ("unable to convert from %s to %s format", from, to);
50}
51
52void
53err_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
64void
66{
67 error ("a cs-list cannot be further indexed");
68}
69
70void
71err_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
76void
78{
79 error ("invalid dimension inquiry of a non-existent value");
80}
81
82void
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
88void
90{
91 error ("invalid assignment to cs-list outside multiple assignment");
92}
93
94void
96{
97 error ("nonconformant matrices");
98}
99
100void
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
109void
110err_not_implemented (const char *fcn)
111{
112 error ("%s: not implemented", fcn);
113}
114
115void
117{
118 error ("range constant used in invalid context");
119}
120
121void
122err_square_matrix_required (const char *fcn, const char *name)
123{
124 error ("%s: %s must be a square matrix", fcn, name);
125}
126
127void
129{
130 error ("std::string constant used in invalid context");
131}
132
133void
135{
136 error ("%s: unrecognized data format requested", name);
137}
138
139void
141{
142 error ("unrecognized floating point format requested");
143}
144
145void
147{
148 error ("%s: user-supplied function returned invalid value", name);
149}
150
151void
152err_user_supplied_eval (const char *name)
153{
154 octave::execution_exception ee;
155
156 err_user_supplied_eval (ee, name);
157}
158
159void
160err_user_supplied_eval (octave::execution_exception& ee, const char *name)
161{
162 error (ee, "%s: evaluation of user-supplied function failed", name);
163}
164
165void
166err_wrong_type_arg (const char *name, const char *s)
167{
168 octave::execution_exception ee;
169
170 err_wrong_type_arg (ee, name, s);
171}
172
173void
174err_wrong_type_arg (octave::execution_exception& ee,
175 const char *name, const char *s)
176{
177 error (ee, "%s: wrong type argument '%s'", name, s);
178}
179
180void
181err_wrong_type_arg (const char *name, const std::string& s)
182{
183 octave::execution_exception ee;
184
185 err_wrong_type_arg (ee, name, s.c_str ());
186}
187
188void
189err_wrong_type_arg (octave::execution_exception& ee,
190 const char *name, const std::string& s)
191{
192 err_wrong_type_arg (ee, name, s.c_str ());
193}
194
195void
196err_wrong_type_arg (const char *name, const octave_value& tc)
197{
198 octave::execution_exception ee;
199
200 err_wrong_type_arg (ee, name, tc);
201}
202
203void
204err_wrong_type_arg (octave::execution_exception& ee,
205 const char *name, const octave_value& tc)
206{
207 std::string type = tc.type_name ();
208
209 err_wrong_type_arg (ee, name, type);
210}
211
212void
213err_wrong_type_arg (const std::string& name, const octave_value& tc)
214{
215 octave::execution_exception ee;
216
217 err_wrong_type_arg (ee, name, tc);
218}
219
220void
221err_wrong_type_arg (octave::execution_exception& ee,
222 const std::string& name, const octave_value& tc)
223{
224 err_wrong_type_arg (ee, name.c_str (), tc);
225}
226
227void
228err_wrong_type_arg (const char *s)
229{
230 octave::execution_exception ee;
231
232 err_wrong_type_arg (ee, s);
233}
234
235void
236err_wrong_type_arg (octave::execution_exception& ee, const char *s)
237{
238 error (ee, "wrong type argument '%s'", s);
239}
240
241void
242err_wrong_type_arg (const std::string& s)
243{
244 octave::execution_exception ee;
245
246 err_wrong_type_arg (ee, s);
247}
248
249void
250err_wrong_type_arg (octave::execution_exception& ee, const std::string& s)
251{
252 err_wrong_type_arg (ee, s.c_str ());
253}
254
255void
257{
258 octave::execution_exception ee;
259
260 err_wrong_type_arg (ee, tc);
261}
262
263void
264err_wrong_type_arg (octave::execution_exception& ee, const octave_value& tc)
265{
266 std::string type = tc.type_name ();
267
268 err_wrong_type_arg (ee, type);
269}
270
271void
273{
274 std::string type = op.type_name ();
275 error ("invalid operand '%s' for binary operator", type.c_str ());
276}
277
278void
280{
281 std::string type = op.type_name ();
282 error ("invalid operand '%s' for unary operator", type.c_str ());
283}
284
285void
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
302void
304{
305 warning_with_id ("Octave:language-extension",
306 "comparing complex numbers is not supported in Matlab");
307}
308
309void
310warn_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
317void
318warn_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
329void
330warn_empty_arg (const char *name)
331{
332 warning ("%s: argument is empty matrix", name);
333}
334
335void
336warn_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
343void
344warn_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
349void
350warn_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
358void
360{
361 warning ("invalid value specified for '%s'", name);
362}
363
364void
366{
367 warning_with_id ("Octave:logical-conversion",
368 "value not equal to 1 or 0 converted to logical 1");
369}
370
371void
372warn_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:90
std::string str(char sep='x') const
Definition dim-vector.cc:68
std::string type_name() const
Definition ov.h:1360
void warning(const char *fmt,...)
Definition error.cc:1078
void warning_with_id(const char *id, const char *fmt,...)
Definition error.cc:1093
void error(const char *fmt,...)
Definition error.cc:1003
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_square_matrix_required(const char *fcn, const char *name)
Definition errwarn.cc:122
void err_data_conversion(const char *from, const char *to)
Definition errwarn.cc:47
void err_2_or_3_dim_plot()
Definition errwarn.cc:41
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 err_unrecognized_float_fmt()
Definition errwarn.cc:140
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_nonconformant()
Definition errwarn.cc:95
void err_user_supplied_eval(const char *name)
Definition errwarn.cc:152
void warn_complex_cmp()
Definition errwarn.cc:303
void warn_array_as_logical(const dim_vector &dv)
Definition errwarn.cc:286
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition errwarn.cc:71
void warn_logical_conversion()
Definition errwarn.cc:365
void err_not_implemented(const char *fcn)
Definition errwarn.cc:110
void err_invalid_structure_assignment()
Definition errwarn.cc:83
void err_indexed_cs_list()
Definition errwarn.cc:65
void err_invalid_inquiry_subscript()
Definition errwarn.cc:77
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_nonbraced_cs_list_assignment()
Definition errwarn.cc:89
void err_range_invalid()
Definition errwarn.cc:116
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
void err_string_invalid()
Definition errwarn.cc:128