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 ErrNum.  Run-time errors are only caught if you have an active ON  ERROR  GOTO in your code.  ERROR is useful to explicitly raise an exception in a TRY/END TRY block.

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"