Tip

Error Handling on Web LotusScript agents

When running LotusScript agents on the web there is no access to a script debugger.

Using the Erl and Error functions within LotusScript you can simply detect the line of your error and display it on the screen.

In a WebQueryOpen agent you cannot "print" to the screen so you can use a field (I have called it called "ErrorField") which is hidden if ErrorField="" On the WebQuerySave or in an ?openagent you can print the error to the Screen.

This also works if the errorhandling is added into functions within the agent as well as the Initialize.

 Sub Initialize On Error Goto ErrorHandler Dim session As New notessession Dim doc as notesdocument Dim db as notesdatabase Set doc=session.documentcontext Set db=session.currentdatabase etc etc etc etc Exit Sub ErrorHandler: Dim ErrString As String ErrString="INITIALIZE : Script Error on Line : " + Cstr(Erl()) + Chr(10)+Chr(10)+"Error Message : " + Error$ Print ErrString 'In WebQueryOpen agent use doc.ErrorField=ErrString Exit Sub End Sub

(When adding the errorhandling into a function replace INITIALIZE with the name of your function to differentiate between failure points)

This was first published in April 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.