7017
|
1 ## Copyright (C) 1995, 1996, 1997, 1999, 2002, 2005, 2006, 2007 |
|
2 ## John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
1576
|
19 |
3381
|
20 ## -*- texinfo -*- |
3373
|
21 ## @deftypefn {Function File} {} strerror (@var{name}, @var{num}) |
|
22 ## Return the text of an error message for function @var{name} |
|
23 ## corresponding to the error number @var{num}. This function is intended |
|
24 ## to be used to print useful error messages for those functions that |
|
25 ## return numeric error codes. |
|
26 ## @end deftypefn |
1576
|
27 |
2314
|
28 ## Author: jwe |
|
29 |
2311
|
30 function msg = strerror (name, err) |
1576
|
31 |
|
32 if (nargin != 2) |
6046
|
33 print_usage (); |
1576
|
34 endif |
|
35 |
5443
|
36 if (! ischar (name)) |
1576
|
37 error ("strerror: first argument must be a string"); |
|
38 endif |
|
39 |
4030
|
40 if (! isscalar (err)) |
1576
|
41 error ("strerror: second argument must be a scalar"); |
|
42 endif |
|
43 |
|
44 if (strcmp (name, "fsolve")) |
|
45 |
|
46 if (err == -2) |
|
47 msg = "input error\n"; |
|
48 elseif (err == -1) |
|
49 msg = "error encountered in user-supplied function\n"; |
|
50 elseif (err == 1) |
|
51 msg = "solution converged to requested tolerance\n"; |
|
52 elseif (err == 4) |
|
53 msg = "iteration limit exceeded\n"; |
|
54 elseif (err == 3) |
|
55 msg = "iteration is not making good progress\n"; |
|
56 else |
|
57 error ("strerror: unrecognized error code for fsolve"); |
|
58 endif |
|
59 |
|
60 else |
|
61 |
|
62 error ("strerror: unrecognized function name"); |
|
63 |
|
64 endif |
|
65 |
|
66 endfunction |