[Scilab-users] Awkward behavior of error handling
Federico Miyara
fmiyara at fceia.unr.edu.ar
Thu Feb 6 22:04:25 CET 2020
Dear All,
I'm trying to cast an error message for a function
The test and message are
if argn(2)<>1
t1 = "%s: Wrong number of input arguments: %d expected.\n"
t2 = "Si"
error(msprintf(gettext(t1),t2,1));
end
The function has only one argument, so if invoked with 0 or more than
one argument, the message should be the same. With 0 arguments I get:
--> y = Si()
0.
at line 26 of function Si ( D:\work_scilab\Si.sci line 26 )
Si: Wrong number of input arguments: 1 expected.
This is the correct and expected message. However, with 2 arguments I get
--> y = Si(1,2)
Wrong number of input arguments.
This error seems to have been trapped before my test, the execution is
halted and my message doesn't show. I've also tested the function
wavwrite, which requires 2 or 3 arguments. With 0 or 1 the message is
the expected one, but with 4 or more arguments, I get the same result as
in my example.
Seems as if less arguments are handled by the custom error handler, but
more than required is handled by sort of a parser.
I think this behavior contradicts the facility of customizing error
messages.
Regards,
Federico Miyara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200206/00be5014/attachment.htm>
More information about the users
mailing list