# HG changeset patch # User Carlo de Falco # Date 1467909200 -7200 # Thu Jul 07 18:33:20 2016 +0200 # Node ID 2dd71325ed8336b47564b4b185f5fc14a1233f4e # Parent 47f4268f8c5eae8fddb75d44c48e1095fc90c5f0 Set error ids in validateattributes * scripts/general/validateattributes.m : Set the error ID to "Octave:invalid-input-arg" for errors thrown in validateattributes. diff --git a/scripts/general/validateattributes.m b/scripts/general/validateattributes.m --- a/scripts/general/validateattributes.m +++ b/scripts/general/validateattributes.m @@ -173,9 +173,11 @@ if (nargin < 3 || nargin > 6) print_usage (); elseif (! iscellstr (cls)) - error ("validateattributes: CLASSES must be a cell array of strings"); + error ("Octave:invalid-input-arg", + "validateattributes: CLASSES must be a cell array of strings"); elseif (! iscell (attr)) - error ("validateattributes: ATTRIBUTES must be a cell array"); + error ("Octave:invalid-input-arg", + "validateattributes: ATTRIBUTES must be a cell array"); endif ## Built start of error message from the extra optional arguments @@ -188,19 +190,22 @@ elseif (nargin == 4 && valid_arg_idx (fourth)) var_name = sprintf ("input %d", fourth); else - error ("validateattributes: 4th input argument must be ARG_IDX or FUNC_NAME"); + error ("Octave:invalid-input-arg", + "validateattributes: 4th input argument must be ARG_IDX or FUNC_NAME"); endif if (nargin > 4) var_name = varargin{2}; if (! ischar (var_name)) - error ("validateattributes: VAR_NAME must be a string"); + error ("Octave:invalid-input-arg", + "validateattributes: VAR_NAME must be a string"); endif if (nargin > 5) arg_idx = varargin{3}; if (! valid_arg_idx (arg_idx)) - error ("validateattributes: ARG_IDX must be a positive integer"); + error ("Octave:invalid-input-arg", + "validateattributes: ARG_IDX must be a positive integer"); endif var_name = sprintf ("%s (argument #%i)", var_name, arg_idx); endif @@ -224,7 +229,8 @@ cls = unique (cls); classes = sprintf (" %s", cls{:}); - error ("%s must be of class:\n\n %s\n\nbut was of class %s", + error ("Octave:invalid-input-arg", + "%s must be of class:\n\n %s\n\nbut was of class %s", err_ini, classes, class (A)); endif @@ -287,47 +293,59 @@ A_size_str = sprintf ("%dx", size (A))(1:end-1); w_size_str = sprintf ("%ix", w_size)(1:end-1); w_size_str = strrep (w_size_str, "NaN", "N"); - error ("%s must be of size %s but was %s", err_ini, w_size_str, A_size_str); + error ("Octave:invalid-input-arg", + "%s must be of size %s but was %s", + err_ini, w_size_str, A_size_str); endif case "numel", if (numel (A) != attr{idx++}) - error ("%s must have %d elements", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must have %d elements", err_ini, attr{idx-1}); endif case "ncols", if (columns (A) != attr{idx++}) - error ("%s must have %d columns", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must have %d columns", err_ini, attr{idx-1}); endif case "nrows", if (rows (A) != attr{idx++}) - error ("%s must have %d rows", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must have %d rows", err_ini, attr{idx-1}); endif case "ndims", ## Note that a [4 5 1] matrix is not considered to have ndims == 3 ## but is ok for "3d". This is not a bug. if (ndims (A) != attr{idx++}) - error ("%s must have %d dimensions", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must have %d dimensions", err_ini, attr{idx-1}); endif case ">" if (! all (A(:) > attr{idx++})) - error ("%s must be greater than %f", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must be greater than %f", err_ini, attr{idx-1}); endif case ">=" if (! all (A(:) >= attr{idx++})) - error ("%s must be greater than or equal to %f", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must be greater than or equal to %f", err_ini, attr{idx-1}); endif case "<" if (! all (A(:) < attr{idx++})) - error ("%s must be less than %f", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must be less than %f", err_ini, attr{idx-1}); endif case "<=" if (! all (A(:) <= attr{idx++})) - error ("%s must be less than or equal to %f", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must be less than or equal to %f", err_ini, attr{idx-1}); endif otherwise - error ("validateattributes: unknown ATTRIBUTE %s", attr{idx-1}); + error ("Octave:invalid-input-arg", + "validateattributes: unknown ATTRIBUTE %s", attr{idx-1}); endswitch if (problem) - error ("%s must be %s", err_ini, attr{idx-1}); + error ("Octave:invalid-input-arg", + "%s must be %s", err_ini, attr{idx-1}); endif endwhile