Re: Retrieving line number of error wit
Posted in 1993
->From: hlt@napcc-hp (Harold Trammel) ->Subject: Retrieving line number of error with err_get ->Date: Tue, 25 May 1993 15:20:01 GMT ->Reply-To: hlt@napcc-hp (Harold Trammel) ->Organization: University of Illinois at Urbana -> ->When the WHENEVER ERROR STOP statement is used in an Informix-4gl program, ->the program aborts and the startlog() function writes the routine name, the ->line number (well, sort of B-) ), the error code, and corresponding error ->message out to the errorlog file. -> ->I would like to have similar behavior with the WHENEVER ERROR CALL (or even ->CONTINUE) statements. I have an error_handler function that uses err_get() ->to read the error messages for the error codes and I put them in the file ->with errorlog(). -> ->How can I get to the routine and line number? I need to have the ->application used by regular users and record the problems that arrise. My ->error_handler just records what the error was, not the approximate location ->of the error. -> I don't know how to get the line number and thought about it many lines of code ago and decided: Naaaaaaah, who cares anyway what the line number is?. Only if you are lucky enough to have available source that matches the executing code will the line number mean anything. (just kidding) Actually, line numbers may be a good way to test this condition. All one has to do is wait for errors! Anyway, all this presumes a contiguous source module. One actually needs to know source module and line number when it's a multiple-module program. Decided that it's probably more meaningful and better documented to do this: ---------------------------------------------------------------------- some_function() whenever error continue specfic_database_op/statement if sqlca.sqlcode <> 0 (or whatever) then call error_routine("some_function: specific op error message", sqlca.sqlcode) call exit_program(exit-value) # optional? end if whenever error stop end some_function ---------------------------------------------------------------------- Yep, one has to actually describe WHERE and WHAT was going on when the error was detected! But what-the-hay, maybe with a good error message one can avoid commenting what the operation was in the first place. I don't know if I'm kidding. Sure, you could invoke (previously submitted) schemes for such things as automating the function name identification but ... 1) 4GL has enough overhead already 2) Unless there is unnecessary source code replication, the error string should be unique 3) Based on (2,above) you can easily grep on the string in the source Important pieces of info that also should be logged/announced are the program/loginid names. Hope this helps ... +-------------------------------+----------------------------------+ | Tim Cargile | INTERNET: tec@netcom4.netcom.com | | Relational Applications Group | Bus. : 510-743-8211 | | POB 31171 Oakland, CA 94604 | FAX : 510-743-0971 | +-------------------------------+----------------------------------+ What this country needs is a good 5 cent Informix Survival Kit