Craig A. Berry wrote: > At 8:19 PM -0700 3/26/08, Hein, Nashua NH wrote: > >> On Mar 26, 9:51 pm, [EMAIL PROTECTED] (Thomas Pfau) wrote: >> >>> I could use some advice on how to handle error returns. >>> > > Thanks for making the effort to thrash out the interface in public. > > >>> The translate routine wants to return a hash reference containing >>> information about the logical. If the logical isn't defined or some >>> other error returns, I'm setting it up to return a scalar containing the >>> status code. Does this sound usable? Should it return undef on error >>> and provide another routine to get the status code? >>> >> That does not sound reasonable to me. >> If something does not work, I expect UNDEF or FALSE. Preferably UNDEF. >> If it does, then I expect a TRUE return. Something useful prefered. >> IMHO It should preferably behave much like OPEN. >> >> Can you stick the real error/return code behind $! ? >> Something like the $lnm->error you show in teh example should work >> also. >> > > I think I agree with Hein that no translation should give you undef > and errors should be handled via $!, which is really just C's errno > with sugar on top. You should be able to do that from XS with > something as simple as: > > SETERRNO(ENOENT, SS$_NOLOGNAM); > XS_RETURN_UNDEF; > > As far as successful returns, you could have an optional second > argument specifying a particular item and return the value of that > item as a scalar, but if the second arg is absent return the hash > with all the values. Just a thought (not necessarily fully baked). > Be sure to look at Dan Sugalski's various VMS::xxx modules -- I think > he has some interfaces like that. > Great ideas. It didn't sound reasonable to me, either, which is why I asked. I forgot about setting $!.
I'll setup the define and create table routines to return the logical or table name. All of the routines will return a true value if successful (the actual VMS status). On error, they'll set $!/$^E and return undef.