ERROR statement

Purpose

Cause a run-time error to be generated and sets ERR to the specified error number.

Syntax

ERROR ErrNum

Remarks

ERROR ErrNum causes a run-time error to be generated and sets ERR to the specified number.  Run-time errors are only caught (through the branch to your error trap routine) if you have an active ON ERROR GOTO or a TRY/END TRY block in your code.

Valid errors are in the range 1 through 255.  Attempting to set an error value outside of that range will convert the value to a run-time Error 5 ("Illegal function call").

The compiler reserves codes 0 through 150, and 241 through 255 for run-time errors.  You may freely use error codes 151 through 240 for your own purposes.

See also

ERL, ERR, ERRCLEAR, ERROR$, Error OverviewError TrappingON ERROR, Run-time Errors

Example

ERROR 5  ' generates error 5 "Illegal Function Call"