From: <car...@us...> - 2012-05-14 08:18:01
|
Revision: 10434 http://octave.svn.sourceforge.net/octave/?rev=10434&view=rev Author: carandraug Date: 2012-05-14 08:17:51 +0000 (Mon, 14 May 2012) Log Message: ----------- inputParser: mention the validator so its known why argument fails Modified Paths: -------------- trunk/octave-forge/main/general/inst/@inputParser/subsref.m Modified: trunk/octave-forge/main/general/inst/@inputParser/subsref.m =================================================================== --- trunk/octave-forge/main/general/inst/@inputParser/subsref.m 2012-05-14 08:03:43 UTC (rev 10433) +++ trunk/octave-forge/main/general/inst/@inputParser/subsref.m 2012-05-14 08:17:51 UTC (rev 10434) @@ -89,7 +89,7 @@ [name, inPar.copy] = shift (inPar.copy); [value, args] = shift (args); if ( !feval (inPar.Required.(name).validator, value) ) - error("%sargument '%s' failed validation %s", inPar.FunctionName, name, func2str (inPar.Required.(name).validator)); + error_invalid (inPar.FunctionName, name, inPar.Required.(name).validator); endif inPar.Results.(name) = value; endfor @@ -124,7 +124,7 @@ args = unshift (args, value); continue else - error("%sinvalid value for parameter '%s'", inPar.FunctionName, name); + error_invalid (inPar.FunctionName, name, inPar.Optional.(name).validator); endif else inPar.Results.(name) = value; @@ -175,7 +175,7 @@ if (!isempty (index)) [name, inPar.copy] = shift (inPar.copy, index); if ( !feval (inPar.(method).(name).validator, value)) - error("%sinvalid value for parameter '%s'", inPar.FunctionName, key); + error_invalid (inPar.FunctionName, key, inPar.(method).(name).validator); endif ## we use the name shifted from 'copy' instead of the key from 'args' in case ## the key is in the wrong case @@ -301,11 +301,16 @@ ## make sure that the given default value is actually valid ## TODO make sure that when using the default, it's only validated once if ( isa (val, 'function_handle') && !strcmpi (method, 'Required') && !feval (val, def) ) - error ("default value does not validate with '%s'", func2str (val) ); + error ("default value for '%s' failed validation with '%s'", name, func2str (val) ); endif endfunction +## this is just for consistency of error message +function error_invalid (prefix, name, val) + error("%sargument '%s' failed validation %s", prefix, name, func2str (val)); +endfunction + ################################################################################ ## very auxiliary functions ################################################################################ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |