Re: Retrieving Informix error msg from within 4gl program
Posted in 1993
In <hlt.729284187@napcc-hp> hlt@napcc-hp (Harold Trammel) writes: >I am developing an error handling function for use in several >Informix-4gl/rds programs. I want to trap the errors, send them to this >function, display the error number _AND_ the Informix error message to a >dialog box on screen. I don't want the program to throw up and quit. I >want the user to see the error and corresponding message. Is there a >hidden way to get the error messages from within the program? Following is my approch to this, the program uses 'whenever error call err_func' function err_func() define err_line char(63), k, l, err_1, err_2 smallint, reply char define message_1, message_2 char(80), mail_it char(120), login char(8) let err_1 = status let err_2 = sqlca.sqlerrd[2] let message_1 = err_get(err_1) let message_2 = err_get(err_2) let k = (80 - length(message_1)) / 2 if k < 0 then let k = 1 end if let l = (80 - length(message_2)) / 2 if l < 0 then let l = 1 end if select user into login from systables where tabid = 1 let err_line = "^", login clipped, "^ was using the program when the abowe", " error occured." call errorlog(err_line) let mail_it = "tail -8 /users/stjs/nemskr/Villur/villur.nkhi | ", "/usr/lib/sendmail -f", login clipped, "@rhi.hi.is gaukur@rhi.hi.is" run mail_it open window w_villa at 2,3 with 13 rows, 76 columns attribute(border, prompt line last-1) display "AN ERROR OCCURED!" at 2,24 attribute(reverse) display "SQL-error number ", err_1 at 4,24 display message_1 clipped at 5,k display "SYSTEM error number ", err_2 at 7,24 display message_2 clipped at 8,l display "PLEASE REPORT THE ERROR TO THE SYSTEM MANAGER IN PHONE ....." at 10,10 attribute(reverse) while true prompt " Hit 'H' to stop running the program: " for char reply if reply matches "[hH]" then exit while end if end while close window w_villa whenever error continue whenever warning continue rollback work whenever error call err_func exit program end function Gaukur.