Re: Error Trapping
Ferlin <ferlin at SANDW.NET> wrote:
> Is there a way to trap errors in Euphoria? I am working
>on a project that involves an index of procedures and functions, the
>problem I am having is when someone enters the name of a function, if
>they do not have the proper number of parameters for that particular
>function Euphoria Issues an Error and aborts the program. Is there a
>way I could trap this parameters error and issue and error message?
This is a good question. Currently, when you get a routine_id(), you have to
know in advance how many parameters it requires, what their types are, and
whether the routine is a procedure or a function. I think it would be kinda
neat if there were another function added to the routine_id() family:
s = routine_info(id)
Where s would be a sequence containing the relevant data:
R_TYPE = 1, -- integer value indicating if this is a
-- procedure or a function
R_PROCEDURE = 1,
R_FUNCTION = 2,
R_PARM_DATA = 2 -- sequence containing the routine id's of all the
-- parameter types for this routine
-- number of parms = length(s[R_PARM_DATA])
Obviously, this kind of thing would at least require the built-in types
(atom(), sequence(), etc.) to return valid routine_id() values, so that the
R_PARM_DATA sequence always gives us valid routine id's.
With this kind of thing available, it would be possible to completely verify
all aspects of a user-entered routine -- how many parameters, what kind of
parameters, and if we should expect a return value.
Gabriel Boehme
|
Not Categorized, Please Help
|
|