Third time is a charm. I added the ability to put in mod name and added the
--comments.. LINE 1, LINE 2 so you can find the line later. The only problem
with some of this is if you add lines of code you have to modify each place
past the lines of code you added where it says LINE 1, LINE 2 and so on.
Making this a bit more maintenance than what one would like to keep up with.
The only other way would be to count the occurances of the line of code
where the line number is incremented. This wouldn't be to bad using the
Search menu ???
Maybe someone has a what of doing this better out there.
--myfile.rmd SET ERROR VARIABLE errvar SET VAR errcap INTEGER = NULL SET VAR vm_fileerrname TEXT = 'myfile.rmd' SET VAR vm_modname TEXT = 'mymod' SET VAR vm_linenum INTEGER = 1 SET VAR errcondition INTEGER = NULL --LINE 1 --ACTUAL LINE OF code --Select statement or something SET VAR errcap = .errvar IF errcap <> 0 THEN SET VAR errcondition = 1 GOTO errhandler LABEL keeprunnin ENDIF --Now increment for next line of code SET VAR vm_linenum = (.vm_linenum + 1) --LINE 2 --ACTUAL LINE OF code --Select statement or something SET VAR errcap = .errvar IF errcap <> 0 THEN SET VAR errcondition = 2 --present a special choice GOTO errhandler LABEL keeprunnin ENDIF --Now increment for next line of code SET VAR vm_linenum = (.vm_linenum + 1) --LINE 3 --Do next Line and so on
--If the routine gets to this next part then it will jump to end
--and Exit Normally
GOTO xitnormal
LABEL errhandler
SELECT errmsg INTO vm_errmsg INDICATOR vm_i1 FROM errmsgs +
WHERE errnum = .errcap
IF errvar <> 0 THEN
SET VAR vm_errmsg = 'Unlisted Error'
ENDIF
SET VAR vm_msg1 TEXT = ('F= ' + .vm_fileerrname + ' M= ' + .vm_modname)
SET VAR vm_msg2 TEXT = ('L= ' + (CTXT(.vm_linenum)))
SET VAR vm_msg3 TEXT = ('Err#= ' + (CTXT(.eercap)))
SET VAR vm_msg4 TEXT = ('Msg= ' + .vm_errmsg)
SET VAR vm_msg TEXT = (.vm_msg1 + ' ' + .vm_msg2 + ' ' + .vm_msg3 + +
' ' + .vm_msg4)
PAUSE FOR 5 USING .vm_msg AT CENTER CENTER
SWITCH (.errcondition)
CASE 1
GOTO keeprunnin
BREAK
CASE 2
--present some kind of choice??
BREAK
CASE 3
--exit but do something first
BREAK
ENDSW
LABEL xitnormal
RETURNTrinity Business Technologies wrote:
Victor,
I was looking for an error handling routine that will provide most of the following information:
* Error number. * Error message. * Error description. * Command file in which error occurred. * Line number at which the error occurred. * Line of code that caused the error.
Thanks,
Rick Brown

