Mercurial > hg > octave-nkf
annotate scripts/general/strerror.m @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | 1740012184f9 |
children |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1995-2011 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
1576 | 18 |
3381 | 19 ## -*- texinfo -*- |
3373 | 20 ## @deftypefn {Function File} {} strerror (@var{name}, @var{num}) |
21 ## Return the text of an error message for function @var{name} | |
22 ## corresponding to the error number @var{num}. This function is intended | |
23 ## to be used to print useful error messages for those functions that | |
24 ## return numeric error codes. | |
25 ## @end deftypefn | |
1576 | 26 |
2314 | 27 ## Author: jwe |
28 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
29 function msg = strerror (name, num) |
1576 | 30 |
31 if (nargin != 2) | |
6046 | 32 print_usage (); |
1576 | 33 endif |
34 | |
5443 | 35 if (! ischar (name)) |
1576 | 36 error ("strerror: first argument must be a string"); |
37 endif | |
38 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
39 if (! isscalar (num)) |
1576 | 40 error ("strerror: second argument must be a scalar"); |
41 endif | |
42 | |
43 if (strcmp (name, "fsolve")) | |
44 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
45 if (num == -2) |
1576 | 46 msg = "input error\n"; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
47 elseif (num == -1) |
1576 | 48 msg = "error encountered in user-supplied function\n"; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
49 elseif (num == 1) |
1576 | 50 msg = "solution converged to requested tolerance\n"; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
51 elseif (num == 3) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
52 msg = "iteration is not making good progress\n"; |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
53 elseif (num == 4) |
1576 | 54 msg = "iteration limit exceeded\n"; |
55 else | |
56 error ("strerror: unrecognized error code for fsolve"); | |
57 endif | |
58 | |
59 else | |
60 | |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11469
diff
changeset
|
61 error ("strerror: unrecognized function NAME"); |
1576 | 62 |
63 endif | |
64 | |
65 endfunction |