Share via


ERROR( ) Function

Returns the error number for the error that triggered an ON ERROR routine.

ERROR( )

Return Values

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.

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

AERROR( ) Function | ERROR | MESSAGE( ) | Error Messages A-Z | Error Messages by Number | ON ERROR | RETRY | RETURN