Re: Retrieving line number of error wit
Posted in 1993
----- Transcript of session follows ----- 421 napcc-hp.tcp... Deferred: Permission denied 550 hlt@napcc-hp... Host unknown: Permission denied ----- Unsent message follows ----- Received: by dyngja.rhi.hi.is (AIX 3.1/UCB 5.61/4.03) id AA21611; Tue, 25 May 93 17:06:06 GMT Date: Tue, 25 May 93 17:06:06 GMT From: gaukur (Kristjan Gaukur Kristjansson) Message-Id: <9305251706.AA21611@dyngja.rhi.hi.is> To: hlt@napcc-hp Subject: Re: Retrieving line number of error with err_get Newsgroups: comp.databases.informix References: <hlt.738343201@napcc-hp> >Short of writing error free code from the onset, is there any way I can get >the routine name and line numbers for my use? This is the function that I call in 'whenever error': function error() define errorline char(63), k, l, error1, error2 smallint, afram char define message1, message2 char(80), posta char(120), login char(8) let error1 = status let error2 = sqlca.sqlerrd[2] let message1 = err_get(error1) let message2 = err_get(error2) let k = (80 - length(message1)) / 2 if k < 0 then let k = 1 end if let l = (80 - length(message2)) / 2 if l < 0 then let l = 1 end if select user into login from systables where tabid = 1 #Find the user that got the error and put him in the errorlog. let errorline = "^", login clipped, "^ was using the program when the above", " error occured." call errorlog(errorline) #Run a Unix command that tails the errorlog file and mails it to me. if NEMSKRHOME[1,3] = "/vd" then let posta = "tail -8 /vd/gaukur/Villur/villur.nkhi | ", "/usr/lib/sendmail -f", login clipped, "@rhi.hi.is gaukur@rhi.hi.is" else let posta = "tail -8 /users/stjs/nemskr/Villur/villur.nkhi | ", "/usr/lib/sendmail -f", login clipped, "@rhi.hi.is gaukur@rhi.hi.is" end if run posta #Open a window where I tell the user what error occured (but not the #module name and line number which I see in my mail). open window w_error at 2,3 with 13 rows, 76 columns attribute(border, prompt line last-1) display "'A' KOM UPP KEYRSLUVILLA!" at 2,24 attribute(reverse) display "SQL-villa numer ", error1 at 4,24 display message1 clipped at 5,k display "KERFIS villa numer ", error2 at 7,24 display message2 clipped at 8,l display "VINSAMLEGA TILKYNNID VILLUNA TIL KERFISSTJORA I SIMA (69)4753" at 10,10 attribute(reverse) while true prompt " Sl'i' ' 'H' til a' h'tta keyrslu: " for char afram if afram matches "[hH]" then exit while end if end while close window w_error whenever error continue whenever warning continue rollback work whenever error call error exit program end function Hope it can be of some help. Gaukur.