GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
errwarn.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2017 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
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
18 along with Octave; see the file COPYING. If not, see
19 <http://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 assignment to cs-list outside multiple assignment");
83 }
84 
85 void
87 {
88  error ("nonconformant matrices");
89 }
90 
91 void
94 {
95  error ("nonconformant matrices (op1 is %dx%d, op2 is %dx%d)",
96  r1, c1, r2, c2);
97 }
98 
99 void
101 {
102  error ("%s: not implemented", fcn);
103 }
104 
105 void
107 {
108  error ("range constant used in invalid context");
109 }
110 
111 void
112 err_square_matrix_required (const char *fcn, const char *name)
113 {
114  error ("%s: %s must be a square matrix", fcn, name);
115 }
116 
117 void
119 {
120  error ("std::string constant used in invalid context");
121 }
122 
123 void
125 {
126  error ("%s: unrecognized data format requested", name);
127 }
128 
129 void
131 {
132  error ("unrecognized floating point format requested");
133 }
134 
135 void
137 {
138  error ("%s: user-supplied function returned invalid value", name);
139 }
140 
141 void
143 {
144  octave::execution_exception e;
145 
146  err_user_supplied_eval (e, name);
147 }
148 
149 void
150 err_user_supplied_eval (octave::execution_exception& e, const char *name)
151 {
152  error (e, "%s: evaluation of user-supplied function failed", name);
153 }
154 
155 void
156 err_wrong_type_arg (const char *name, const char *s)
157 {
158  octave::execution_exception e;
159 
160  err_wrong_type_arg (e, name, s);
161 }
162 
163 void
164 err_wrong_type_arg (octave::execution_exception& e,
165  const char *name, const char *s)
166 {
167  error (e, "%s: wrong type argument '%s'", name, s);
168 }
169 
170 void
171 err_wrong_type_arg (const char *name, const std::string& s)
172 {
173  octave::execution_exception e;
174 
175  err_wrong_type_arg (e, name, s.c_str ());
176 }
177 
178 void
179 err_wrong_type_arg (octave::execution_exception& e,
180  const char *name, const std::string& s)
181 {
182  err_wrong_type_arg (e, name, s.c_str ());
183 }
184 
185 void
186 err_wrong_type_arg (const char *name, const octave_value& tc)
187 {
188  octave::execution_exception e;
189 
190  err_wrong_type_arg (e, name, tc);
191 }
192 
193 void
194 err_wrong_type_arg (octave::execution_exception& e,
195  const char *name, const octave_value& tc)
196 {
197  std::string type = tc.type_name ();
198 
199  err_wrong_type_arg (e, name, type);
200 }
201 
202 void
204 {
205  octave::execution_exception e;
206 
207  err_wrong_type_arg (e, name, tc);
208 }
209 
210 void
211 err_wrong_type_arg (octave::execution_exception& e,
212  const std::string& name, const octave_value& tc)
213 {
214  err_wrong_type_arg (e, name.c_str (), tc);
215 }
216 
217 void
218 err_wrong_type_arg (const char *s)
219 {
220  octave::execution_exception e;
221 
222  err_wrong_type_arg (e, s);
223 }
224 
225 void
226 err_wrong_type_arg (octave::execution_exception& e, const char *s)
227 {
228  error (e, "wrong type argument '%s'", s);
229 }
230 
231 void
233 {
234  octave::execution_exception e;
235 
236  err_wrong_type_arg (e, s);
237 }
238 
239 void
240 err_wrong_type_arg (octave::execution_exception& e, const std::string& s)
241 {
242  err_wrong_type_arg (e, s.c_str ());
243 }
244 
245 void
247 {
248  octave::execution_exception e;
249 
250  err_wrong_type_arg (e, tc);
251 }
252 
253 void
254 err_wrong_type_arg (octave::execution_exception& e, const octave_value& tc)
255 {
256  std::string type = tc.type_name ();
257 
258  err_wrong_type_arg (e, type);
259 }
260 
261 void
263 {
264  std::string type = op.type_name ();
265  error ("invalid operand '%s' for binary operator", type.c_str ());
266 }
267 
268 void
270 {
271  std::string type = op.type_name ();
272  error ("invalid operand '%s' for unary operator", type.c_str ());
273 }
274 
275 void
277 {
278  warning_with_id ("Octave:array-as-logical",
279  "Using an object of size %s as "
280  "a boolean value implies all().",
281  dv.str ().c_str ());
282 }
283 
284 /*
285 %!warning <boolean value implies all>
286 %! warning ("on", "Octave:array-as-logical");
287 %! if ([1 1 0])
288 %! assert (false);
289 %! endif
290 */
291 
292 void
294 {
295  warning_with_id ("Octave:language-extension",
296  "comparing complex numbers is not supported in Matlab");
297 }
298 
299 void
301 {
302  warning_with_id ("Octave:data-file-in-path",
303  "%s: '%s' found by searching load path",
304  fcn.c_str (), file.c_str ());
305 }
306 
307 void
309  const std::string& pkg /*="Octave"*/)
310 {
311  if (! fcn.empty ())
312  warning ("%s: support for %s was unavailable or disabled when %s was built",
313  fcn.c_str (), feature.c_str (), pkg.c_str ());
314  else
315  warning ("support for %s was unavailable or disabled when %s was built",
316  feature.c_str (), pkg.c_str ());
317 }
318 
319 void
321 {
322  warning_with_id ("Octave:divide-by-zero", "division by zero");
323 }
324 
325 void
326 warn_empty_arg (const char *name)
327 {
328  warning ("%s: argument is empty matrix", name);
329 }
330 
331 void
332 warn_implicit_conversion (const char *id, const char *from, const char *to)
333 {
334  warning_with_id (id, "implicit conversion from %s to %s", from, to);
335 }
336 
337 void
339  const std::string& from, const std::string& to)
340 {
341  warning_with_id (id.c_str (),
342  "implicit conversion from %s to %s",
343  from.c_str (), to.c_str ());
344 }
345 
346 void
348 {
349  warning ("invalid value specified for '%s'", name);
350 }
351 
352 void
354 {
355  warning_with_id ("Octave:logical-conversion",
356  "value not equal to 1 or 0 converted to logical 1");
357 }
358 
359 void
360 warn_wrong_type_arg (const char *name, const octave_value& tc)
361 {
362  std::string type = tc.type_name ();
363 
364  warning ("%s: wrong type argument '%s'", name, type.c_str ());
365 }
void warn_empty_arg(const char *name)
Definition: errwarn.cc:326
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:803
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:120
void warn_invalid_value_specified(const char *name)
Definition: errwarn.cc:347
std::string str(char sep= 'x') const
Definition: dim-vector.cc:73
void err_nonbraced_cs_list_assignment(void)
Definition: errwarn.cc:80
void warn_logical_conversion(void)
Definition: errwarn.cc:353
void err_unrecognized_data_fmt(const char *name)
Definition: errwarn.cc:124
void err_string_invalid(void)
Definition: errwarn.cc:118
void error(const char *fmt,...)
Definition: error.cc:570
void err_wrong_type_arg_for_unary_op(const octave_value &op)
Definition: errwarn.cc:269
void err_square_matrix_required(const char *fcn, const char *name)
Definition: errwarn.cc:112
s
Definition: file-io.cc:2682
i e
Definition: data.cc:2724
octave_function * fcn
Definition: ov-class.cc:1743
void err_nonconformant(void)
Definition: errwarn.cc:86
void err_indexed_cs_list(void)
Definition: errwarn.cc:62
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
void warn_data_file_in_path(const std::string &fcn, const std::string &file)
Definition: errwarn.cc:300
void err_range_invalid(void)
Definition: errwarn.cc:106
void err_wrong_type_arg_for_binary_op(const octave_value &op)
Definition: errwarn.cc:262
void warn_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:308
idx type
Definition: ov.cc:3129
void warn_divide_by_zero(void)
Definition: errwarn.cc:320
void warn_complex_cmp(void)
Definition: errwarn.cc:293
void err_unrecognized_float_fmt(void)
Definition: errwarn.cc:130
may be zero for pure relative error test tem the relative tolerance must be greater than or equal to
Definition: Quad-opts.cc:233
void err_wrong_type_arg(const char *name, const char *s)
Definition: errwarn.cc:156
void warning(const char *fmt,...)
Definition: error.cc:788
std::string type_name(void) const
Definition: ov.h:1232
void err_user_supplied_eval(const char *name)
Definition: errwarn.cc:142
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:68
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:332
void warn_wrong_type_arg(const char *name, const octave_value &tc)
Definition: errwarn.cc:360
void err_invalid_inquiry_subscript(void)
Definition: errwarn.cc:74
void warn_array_as_logical(const dim_vector &dv)
Definition: errwarn.cc:276
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:100
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:50
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:854
dim_vector dv
Definition: sub2ind.cc:263
void err_user_returned_invalid(const char *name)
Definition: errwarn.cc:136