Handling run-time errors

See "File contents" for a list of error messages.

The Domino® Designer methods raise run-time errors to flag most conditions. To process errors, you must include an error-handling routine; if you do not, the script exits when an error occurs.

Some methods return a status value or return Nothing as an object handle to flag a condition; in these cases, the return value can be checked before proceeding. Some properties indicate status, and can be checked after calling a method that affects the status value.

For example, you can detect a failure of the New or Open method of NotesDatabase through any of the following indicators:

  • An attempt to use the object with a method that requires an open database raises the error lsERR_NOTES_DATABASE_NOTOPEN (4063). Be aware that the error occurs when you try to use the object after the open is attempted, not when the open is attempted. In addition, using properties of the object does not raise an error.
  • The object property IsOpen is False.
  • If you used the Open method, the return value is False.

LotusScript® raises run-time errors for many conditions, such as file errors and arithmetic exceptions. You must handle these errors if you do not want the script to exit on an error.

To trap all errors, include an On Error statement without an error number before any executable statements. To trap a specific error, include an On Error statement with the error number before the statement that might cause the error. However, the On Error statements with numbers must follow the On Error statement without a number. For example, if you want to trap the errors lsERR_NOTES_DATABASE_NOTOPEN and ErrObjectVariableNotSet plus any other errors, you need to write the following On Error statements in the following order:

On Error Goto processError
On Error ErrObjectVariableNotSet Goto processErrObjectVariableNotSet

The error constants are defined in the following files in the Domino® data directory. You must include the appropriate file or files in the (Declarations) event of the object to access the error constants. You can create a script library with the %include statements, and then use that script library in the options section.

  • lsxbeerr.lss defines constants for errors raised by Domino® Designer back-end methods.
  • lsxuierr.lss defines constants for errors raised by Domino® Designer front-end (UI) methods.
  • lserr.lss defines constants for errors raised by LotusScript®.
  • lsconst.lss defines constants for use as arguments in LotusScript® statements and functions.