ERROR


General Form:
ERROR general form
Where:
statement = any KCML statement


The ERROR statement provides a means of handling recoverable program execution errors, by suppressing the normal error response and passing control to the program.

When an error is detected in a statement that is immediately followed by an ERROR statement, the normal error response is suppressed, and program execution continues with the statement immediately following the ERROR statement. All of the statements on the line after the ERROR statement are executed if an error occurred. If no error occurred then execution continues with the next line of the program, unless the ERROR statement is followed by a DO group, then execution continues with the statement following the DO group. If the next statement after the DO group is an ELSE then that statement will be skipped in the error case and executed if no error.

The ERROR statement can only be used to detect a recoverable error which (generally) has a code of 48 or is within the range of 65 to 99. The recovery status of an error (RECOVerable or FATAL) may be found in the file berror.d. Errors which have been suppressed with the SELECT ERROR statement will not be detected with the ERROR statement.

Compatibility

Modern programs should use the structured TRY/CATCH mechanism introduced with KCML 6.20. Structured error handling takes precedence over the ERROR and ON ERROR statements. The ERROR statement is not allowed at $COMPLIANCE level 3 and above.

Example:

LOAD program$: ERROR DO
     action = junk
     'DisplayError()
ENDDO

See also:

TRY, THROW, ON ERROR, SELECT ERROR, DO group, ERR, ERROR, ERR$(