RE: WHENEVER ANY ERROR CONTINUE fails
Posted in 1998
Dan, You are very fortunate that I'd written my response before I noticed your email address. Normally, I won't respond to people who use anti-spamming addresses! If I'd noticed, you'd have gotten no response from me, that's for sure. Don't do it! And don't whinge to me about the volume of email you get. ---------- From: Daniel Wright[SMTP:nospam@nobugme.cya] Sent: Monday, May 11, 1998 10:05 PM To: informix-list@iiug.org Subject: WHENEVER ANY ERROR CONTINUE fails Has anyone seen this happen? Does anyone know a fix? details...details...yes HP-UX 10.20 Informix 7.21.UC1 All 4GL A Library function in one module called from a function in another library module. The 2nd nested library module function has the "WHENEVER ANY ERROR CONTINUE" statement, and then calls another function within its own module. This called function has a PREPARE, which has a syntax error, but instead of "CONTINUE"ing, it dies (no core dump, no nothing....but to STDERR, a la WHENEVER ERROR STOP)....I've carefully studied the code, and there are no intermediate functions which could change this. OK: Let's make this a bit clearer with code fragments: {--file1.4gl-} FUNCTION LibFunc1() CALL LibFunc2() END FUNCTION {--file2.4gl-} FUNCTION LibFunc2() WHENEVER ERROR CONTINUE CALL LibFunc3() END FUNCTION {--somewhere.4gl-} FUNCTION LibFunc3() PREPARE ... END FUNCTION And LibFunc3() is behaving as if WHENEVER ERROR STOP is in effect. I've placed LibFunc3() in an different file from LibFunc2(), but it could be in the file2.4gl as well. I suspect, though, that if you look at the context where LibFunc3() is compiled, the prevailing WHENEVER ERROR handling is STOP. The key question is: what is the error handling mode when LibFunc3() is compiled. The WHENEVER directives are compiler directives, not run-time directives. If LibFunc3() is compiled with WHENEVER ERROR STOP, then nothing in any of the calling functions will ever make it behave at run-time in any other way - it will stop if an error occurs. In my view, there is seldom a reason not to enclose a PREPARE statement within WHENEVER ERROR CONTINUE and WHENEVER ANY ERROR STOP statements, and then explicitly do the error checking; there are far too many ways a PREPARE can go wrong for me to ever want to have WHENEVER ERROR STOP in operation. [If that's not clear....there is a program, call it "A", which is linked to 2 separate libraries "L1" and "L2". "A" calls a function in "L1", which calls a function in "L2". "L2" explicitly says "WHENEVER ANY ERROR CONTINUE", something which was also in "A". The function called in "L2" (from "L1") calls another function in "L2" which contains a syntax error. The program stops, spits out to stderr.] That's it for the other one. I swear to god there are no intervening function calls which might set "WHENEVER ANY ERROR STOP" or even "WHENEVER ERROR STOP" in between. I did a simple test case to verify that "WHENEVER ANY ERROR CONTINUE" does work, and even included the error in another module (alhtough it was not a library), and it certainly was not one library function called from another library function, but it worked as expectd (and has been working for some months now.) As always, many thanks for any input.... - Danny Wright reply to danwright@toofgib.com (reverser toofgib to get bigfoot.....just trying to keep the SPAM to a minimum)