IB Statements/error

From CometWiki

Jump to: navigation, search

ERROR statement

Syntax: ERROR

Discussion: The ERROR statement invokes a non-recoverable runtime error termination procedure. It is typically used as an escape path for unanticipated runtime exceptions in an exception routine.

Execution of the ERROR statement closes all logical unit numbers, terminates program execution and runs QENDITOR (the Comet runtime error utility program) to display error-diagnostic information on the controlling terminal.

Example:

 READ (1,1000) KEY=CUSTNUM$, EXCP=BRANCH1
 .
  BRANCH1:  IF EXCP=33 THEN ...
         IF EXCP=32 THEN ...
         ERROR

In the above example, an exception routine is established at the statement label BRANCH1. In this routine, the Comet system variable EXCP is interrogated. If its value is 33 (indicating that a data record is extracted by another user) or 32 (indicating that the particular key was not found in the file), specific actions are taken (although not shown in the above program segment).

However, if the value if EXCP is anything other than 33 or 32, the program executes the ERROR statement and terminates execution of the program.

Personal tools