Returns the error number for the error that triggered an ON ERROR routine.
ERROR( ) |
Return Value
Numeric
Remarks
ERROR( ) returns the number of the most recent error. An ON ERROR routine must be active for ERROR( ) to return a value other than 0.
When an error is trapped during program execution, the error type can be returned by ERROR( ) in an ON ERROR routine. The corresponding error message can be returned by MESSAGE( ).
The value ERROR( ) returns is reset by RETURN or RETRY.
Example
The following example demonstrates a simple error-handling routine that displays a message when an error occurs.
Copy Code | |
|---|---|
CLEAR ON ERROR DO errhand WITH ERROR( ), MESSAGE( ) *** The next line generates an error - there is no BRWSE command BRWSE ON ERROR RETURN *** Error handler *** PROCEDURE errhand PARAMETER errnum,message ? Message ? 'Error number: '+ ALLTRIM(STR(Errnum)) RETURN | |
See Also
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08Send feedback on this topic to the VFPX Help file project team.
2009-2017 Placed under Creative Commons licensing by Microsoft Corporation.