changelog shortlog tags changeset files revisions annotate raw

scripts/general/strerror.m

changeset 10289: 4b124317dc38
parent:93c65f2a5668
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (47 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 1995, 1996, 1997, 1999, 2002, 2005, 2006, 2007
2## John W. Eaton
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
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
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
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
19
20## -*- texinfo -*-
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
27
28## Author: jwe
29
30function msg = strerror (name, err)
31
32 if (nargin != 2)
33 print_usage ();
34 endif
35
36 if (! ischar (name))
37 error ("strerror: first argument must be a string");
38 endif
39
40 if (! isscalar (err))
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
66endfunction