Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning the syntax that triggers an error

Status
Not open for further replies.

mdav2

Programmer
Aug 22, 2000
363
GB
is there anyway to return the syntax that triggers the error? I know that the lineno() and program() can be used to track down the program and line but then you have to open these to locate the error.

I am probably being a bit lazy but it would be very useful.
 
mdav

You need to write a procedure calledd ErrorTrap or similar

ON ERROR DO ErrorTrap WITH ;
[tab]SYS(16),;
[tab]LINENO(),;
[tab]ERROR(),;
[tab]MESSAGE(1),;
[tab]MESSAGE()

*************************
* Procedure: ERRORTRAP
* Syntax: DO ERRORTRAP
* ***********************
PROC ErrorTrap
PARAMETERS lcProgramName,;
[tab]lnLineNumber,;
[tab]lnError,;
[tab]lcErrorMessage,;
[tab]lcErrorType

* Code

ENDPROC

You can add all sorts of other information into the procedure, such as tablename, record no, EOF(), SYS(0), SYS(5), SYS(2003), RELATION(), FILTER() etc, and produce a concatenated mini report which can the be appended into a memo field in a table called ERRORLOG or similar.

At the end of the procedure, DO FORM ERRORLOG, which will then allow you or user to view the error and then CONTINUE, RETRY, QUIT etc.

HTH

Chris
 
Right diagnosis: you already all know !
on error do myError with program(), lineno()
...
proc myError
...here you may do various activity:
- save error in error table
- call it
- for certain error code do appropriate activity
... and finally return/retry.
As it is specific for each case,
you must it write oneself...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top