Run-time error processing

A run-time error occurs either when executing a statement results in an error or when LotusScript® executes an Error statement.

At any time during execution, there is either a current error, or no error at all. The current error is a run-time error that has occurred, but has not yet beenhandled. LotusScript® records the line number in the script where the error occurred, the error number, and the error message associated with that number, if any. Until an error handling routine is invoked for this error, or another error is encountered, these are, respectively, the return values of the functions Erl, Err, and Error$. (Exception: The Err statement can be used to reset the current error number returned by the Err function.)

LotusScript® then looks in the current procedure for an On Error statement associated with this error first, or more commonly, to "clear" the error: an On Error n statement, where n is the error number; if none, an On Error statement with no error number specified. If none is found, the search continues in the procedure that called this procedure, if any; and so on. For the error to be handled in the current procedure, the procedure must include an On Error statement already executed that refers to the error. If no associated On Error statement is found in any calling procedure, execution ends and LotusScript® displays the associated error message.

If an associated On Error statement is found, LotusScript® executes the command contained in the On Error statement.