Re: WHENEVER ANY ERROR
Posted in 1997
Dear Guys, My 0.02 worths. I always thought that WHENEVER ERROR is a "COMPILER DIRECTIVE" and has no effect at run time. Code sequentially in the file after the WHENEVER ERROR statement will follow whatever is set. All the way through the program until the next WHENEVER ERROR is hit. It is evaluated at COMPILE time not RUN time. HTH, Jason On 7 Aug 1997 13:23:06 -0400, johnl@informix.com (Jonathan Leffler) wrote: >>From: Peter Lancashire <Peter.Lancashire.PL1@bayer.co.uk> >>Date: Thu, 07 Aug 1997 10:16:30 +0100 >>X-Informix-List-Id: <news.41339> >> >>Alan Denney wrote: >>> Jojean <jojean@aol.com> wrote: >>> >We are changing some 4GL programs to use WHENEVER ERROR to >>> >WHENEVER ANY ERROR. >>> >>> Good move, generally. >>> >>> >We have gotten some strange results. >> >>I have found a nasty bug in 4GL 6.02 on SCO where attempts to turn off >>the error trapping fail. This results in a C error in the next function >>when it can't find the label the WHENEVER ERROR GOTO directive referred >>to in the previous function. > >This is a (mis)feature of the WHENEVER statement, rather than a bug per >se. If you use WHENEVER ANY ERROR GOTO in FunctionA(), then you should >remember to turn it off (with WHENEVER ANY ERROR STOP) before the END >FUNCTION for FunctionA(). If you don't, then the code which pops the >arguments to FunctionB() which follows will use the same error handling >as FunctionA(), so you have to have the same label in FunctionB() as you >had in FunctionA(). You can only reliably change the error handling in >FunctionB() after the arguments have been popped. (The p-code compiler >in either NewEra or I4GL (I forget which) uses the WHENEVER statement in >FunctionB() if it is the first statement after the variable definitions >before it pops the arguments off the stack, but the corresponding c-code >compiler doesn't, so you shouldn't try to rely on being able to do it). > >Remedies: >1. Don't use WHENEVER ... GOTO >2. Limit the scope of WHENEVER...GOTO to a single function. > >>Sounds as if this problem is unrelated, though. If not, add WHENEVER >>ERROR CALL no_action where no_action() is a do-nothing function you >>write. >> >>Ever wished 4GL had real error trapping and frames like SPL? > >Well, ideally the WHENEVER ERROR directive should be constrained to the >function in which it is written. The SPL exceptions are fairly nifty in >many ways. > >Yours, >Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> >PS: Warning I do not reply to messages with anti-spam in the return path.