GNU Octave  4.4.1
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-2018 Rik Wehbring
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 (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "defun.h"
28 #include "error.h"
29 #include "errwarn.h"
30 #include "ovl.h"
31 #include "utils.h"
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 // Alphabetized list of common errors and warnings.
35 ////////////////////////////////////////////////////////////////////////////////
36 
37 void
39 {
40  error ("plot: can only plot in 2 or 3 dimensions");
41 }
42 
43 void
44 err_data_conversion (const char *from, const char *to)
45 {
46  error ("unable to convert from %s to %s format", from, to);
47 }
48 
49 void
51  const std::string& pkg /* ="Octave" */)
52 {
53  if (! fcn.empty ())
54  error ("%s: support for %s was unavailable or disabled when %s was built",
55  fcn.c_str (), feature.c_str (), pkg.c_str ());
56  else
57  error ("support for %s was unavailable or disabled when %s was built",
58  feature.c_str (), pkg.c_str ());
59 }
60 
61 void
63 {
64  error ("a cs-list cannot be further indexed");
65 }
66 
67 void
69 {
70  error ("invalid conversion from %s to %s", from.c_str (), to.c_str ());
71 }
72 
73 void
75 {
76  error ("invalid dimension inquiry of a non-existent value");
77 }
78 
79 void
81 {
82  error ("invalid dot name structure assignment because the structure array is empty. Specify a subscript on the structure array to resolve.");
83 }
84 
85 void
87 {
88  error ("invalid assignment to cs-list outside multiple assignment");
89 }
90 
91 void
93 {
94  error ("nonconformant matrices");
95 }
96 
97 void
100 {
101  error ("nonconformant matrices (op1 is %dx%d, op2 is %dx%d)",
102  r1, c1, r2, c2);
103 }
104 
105 void
107 {
108  error ("%s: not implemented", fcn);
109 }
110 
111 void
113 {
114  error ("range constant used in invalid context");
115 }
116 
117 void
118 err_square_matrix_required (const char *fcn, const char *name)
119 {
120  error ("%s: %s must be a square matrix", fcn, name);
121 }
122 
123 void
125 {
126  error ("std::string constant used in invalid context");
127 }
128 
129 void
131 {
132  error ("%s: unrecognized data format requested", name);
133 }
134 
135 void
137 {
138  error ("unrecognized floating point format requested");
139 }
140 
141 void
143 {
144  error ("%s: user-supplied function returned invalid value", name);
145 }
146 
147 void
149 {
150  octave::execution_exception e = make_execution_exception ("error");
151 
153 }
154 
155 void
156 err_user_supplied_eval (octave::execution_exception& e, const char *name)
157 {
158  error (e, "%s: evaluation of user-supplied function failed", name);
159 }
160 
161 void
162 err_wrong_type_arg (const char *name, const char *s)
163 {
164  octave::execution_exception e = make_execution_exception ("error");
165 
167 }
168 
169 void
170 err_wrong_type_arg (octave::execution_exception& e,
171  const char *name, const char *s)
172 {
173  error (e, "%s: wrong type argument '%s'", name, s);
174 }
175 
176 void
177 err_wrong_type_arg (const char *name, const std::string& s)
178 {
179  octave::execution_exception e = make_execution_exception ("error");
180 
181  err_wrong_type_arg (e, name, s.c_str ());
182 }
183 
184 void
185 err_wrong_type_arg (octave::execution_exception& e,
186  const char *name, const std::string& s)
187 {
188  err_wrong_type_arg (e, name, s.c_str ());
189 }
190 
191 void
192 err_wrong_type_arg (const char *name, const octave_value& tc)
193 {
194  octave::execution_exception e = make_execution_exception ("error");
195 
196  err_wrong_type_arg (e, name, tc);
197 }
198 
199 void
200 err_wrong_type_arg (octave::execution_exception& e,
201  const char *name, const octave_value& tc)
202 {
203  std::string type = tc.type_name ();
204 
206 }
207 
208 void
210 {
211  octave::execution_exception e = make_execution_exception ("error");
212 
213  err_wrong_type_arg (e, name, tc);
214 }
215 
216 void
217 err_wrong_type_arg (octave::execution_exception& e,
218  const std::string& name, const octave_value& tc)
219 {
220  err_wrong_type_arg (e, name.c_str (), tc);
221 }
222 
223 void
224 err_wrong_type_arg (const char *s)
225 {
226  octave::execution_exception e = make_execution_exception ("error");
227 
229 }
230 
231 void
232 err_wrong_type_arg (octave::execution_exception& e, const char *s)
233 {
234  error (e, "wrong type argument '%s'", s);
235 }
236 
237 void
239 {
240  octave::execution_exception e = make_execution_exception ("error");
241 
243 }
244 
245 void
246 err_wrong_type_arg (octave::execution_exception& e, const std::string& s)
247 {
248  err_wrong_type_arg (e, s.c_str ());
249 }
250 
251 void
253 {
254  octave::execution_exception e = make_execution_exception ("error");
255 
256  err_wrong_type_arg (e, tc);
257 }
258 
259 void
260 err_wrong_type_arg (octave::execution_exception& e, const octave_value& tc)
261 {
262  std::string type = tc.type_name ();
263 
265 }
266 
267 void
269 {
270  std::string type = op.type_name ();
271  error ("invalid operand '%s' for binary operator", type.c_str ());
272 }
273 
274 void
276 {
277  std::string type = op.type_name ();
278  error ("invalid operand '%s' for unary operator", type.c_str ());
279 }
280 
281 void
283 {
284  warning_with_id ("Octave:array-as-logical",
285  "Using an object of size %s as "
286  "a boolean value implies all().",
287  dv.str ().c_str ());
288 }
289 
290 /*
291 %!warning <boolean value implies all>
292 %! warning ("on", "Octave:array-as-logical");
293 %! if ([1 1 0])
294 %! assert (false);
295 %! endif
296 */
297 
298 void
300 {
301  warning_with_id ("Octave:language-extension",
302  "comparing complex numbers is not supported in Matlab");
303 }
304 
305 void
307 {
308  warning_with_id ("Octave:data-file-in-path",
309  "%s: '%s' found by searching load path",
310  fcn.c_str (), file.c_str ());
311 }
312 
313 void
315  const std::string& pkg /*="Octave"*/)
316 {
317  if (! fcn.empty ())
318  warning ("%s: support for %s was unavailable or disabled when %s was built",
319  fcn.c_str (), feature.c_str (), pkg.c_str ());
320  else
321  warning ("support for %s was unavailable or disabled when %s was built",
322  feature.c_str (), pkg.c_str ());
323 }
324 
325 void
327 {
328  warning_with_id ("Octave:divide-by-zero", "division by zero");
329 }
330 
331 void
332 warn_empty_arg (const char *name)
333 {
334  warning ("%s: argument is empty matrix", name);
335 }
336 
337 void
338 warn_implicit_conversion (const char *id, const char *from, const char *to)
339 {
340  warning_with_id (id, "implicit conversion from %s to %s", from, to);
341 }
342 
343 void
345  const std::string& from, const std::string& to)
346 {
347  warning_with_id (id.c_str (),
348  "implicit conversion from %s to %s",
349  from.c_str (), to.c_str ());
350 }
351 
352 void
354 {
355  warning ("invalid value specified for '%s'", name);
356 }
357 
358 void
360 {
361  warning_with_id ("Octave:logical-conversion",
362  "value not equal to 1 or 0 converted to logical 1");
363 }
364 
365 void
366 warn_wrong_type_arg (const char *name, const octave_value& tc)
367 {
368  std::string type = tc.type_name ();
369 
370  warning ("%s: wrong type argument '%s'", name, type.c_str ());
371 }
void warn_empty_arg(const char *name)
Definition: errwarn.cc:332
std::string str(char sep='x') const
Definition: dim-vector.cc:73
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:816
void err_data_conversion(const char *from, const char *to)
Definition: errwarn.cc:44
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
void warn_invalid_value_specified(const char *name)
Definition: errwarn.cc:353
void err_nonbraced_cs_list_assignment(void)
Definition: errwarn.cc:86
void warn_logical_conversion(void)
Definition: errwarn.cc:359
void err_unrecognized_data_fmt(const char *name)
Definition: errwarn.cc:130
void err_string_invalid(void)
Definition: errwarn.cc:124
void error(const char *fmt,...)
Definition: error.cc:578
void err_wrong_type_arg_for_unary_op(const octave_value &op)
Definition: errwarn.cc:275
void err_square_matrix_required(const char *fcn, const char *name)
Definition: errwarn.cc:118
s
Definition: file-io.cc:2729
i e
Definition: data.cc:2591
octave_function * fcn
Definition: ov-class.cc:1754
void err_nonconformant(void)
Definition: errwarn.cc:92
void err_indexed_cs_list(void)
Definition: errwarn.cc:62
nd deftypefn *std::string name
Definition: sysdep.cc:647
void warn_data_file_in_path(const std::string &fcn, const std::string &file)
Definition: errwarn.cc:306
void err_range_invalid(void)
Definition: errwarn.cc:112
void err_invalid_structure_assignment(void)
Definition: errwarn.cc:80
void err_wrong_type_arg_for_binary_op(const octave_value &op)
Definition: errwarn.cc:268
void warn_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:314
idx type
Definition: ov.cc:3114
void warn_divide_by_zero(void)
Definition: errwarn.cc:326
void warn_complex_cmp(void)
Definition: errwarn.cc:299
void err_unrecognized_float_fmt(void)
Definition: errwarn.cc:136
void err_wrong_type_arg(const char *name, const char *s)
Definition: errwarn.cc:162
void warning(const char *fmt,...)
Definition: error.cc:801
void err_user_supplied_eval(const char *name)
Definition: errwarn.cc:148
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:68
octave::execution_exception make_execution_exception(const char *who)
Definition: error.cc:341
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:338
void warn_wrong_type_arg(const char *name, const octave_value &tc)
Definition: errwarn.cc:366
void err_invalid_inquiry_subscript(void)
Definition: errwarn.cc:74
void warn_array_as_logical(const dim_vector &dv)
Definition: errwarn.cc:282
void err_2_or_3_dim_plot(void)
Definition: errwarn.cc:38
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
void err_not_implemented(const char *fcn)
Definition: errwarn.cc:106
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:50
std::string type_name(void) const
Definition: ov.h:1289
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
dim_vector dv
Definition: sub2ind.cc:263
void err_user_returned_invalid(const char *name)
Definition: errwarn.cc:142