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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping two kinds of errors ?

Status
Not open for further replies.

sarah77

Programmer
Jun 4, 2002
36
0
0
US
I'd like to trap two knids of errors. These are :
- Index does not match.
- Validate database.

Does anybody knows how to use ON ERROR command to trap and simulate these two errors.

Any help will be much appriciated.

Thanks
 
114 - "Index does not match the table. Delete the index file and re-create the index."

1561 - "Database is invalid. Please validate."

To simulate them just use:
ERROR 114
ERROR 1561

Using ON ERROR for these number will "trap" them.

Rick
 
And note: ON ERROR must handle ALL errors: It's impossible in VFP to have the error handler only called for certain errors.
 
You can make it look like it does, though. Put this in your error handler:
[tt]
Procedure MyError
nErrCode=ERROR()
DO CASE
CASE nErrCode=114 && Index does not match
&& Process the error
CASE nErrCode=1561 && Database is invalid
&& Process the error
OTHERWISE
ON ERROR
RETRY
ENDDO
[/tt]
What this does is, if the error handler doesn't know what to do with the error, will kill the error handler and try the command again. This, of course, will cause the default VFP error handler to pop up with the CANCEL, SUSPEND, IGNORE, HELP buttons.

You probably wouldn't want to ever do this except for debugging small projects, but I thought it might come in handy somewhere.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top