developerWorks  >  Lotus  >  Forums & community  >  IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)

IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)



Feedback Type
Subject Error trap
Product Area
Technical Area
Platform
Release
You might want to add error trapping in the code. Here is an example

Sub Initialize
'The following line says to jump to the label called ErrorHandler if there is an error.
On Error Goto ErrorHandler

Dim s As New NotesSession
Dim thisAgent As NotesAgent

'This is used to obtain the name of the agent currently running.
Set thisAgent = s.CurrentAgent

'Your code goes here

'The Done label is there so you can reference it in your ErrorHandler.
'The Exit Sub jumps past the ErrorHanlder if the code above successfully completes.
Done:
Exit Sub
ErrorHandler:
'The Select statement enables you to handle test for different errors. For example,
'when Err is 53, it indicates "File not found." With some errors, you might choose to
'skip to the next line of code, rather than exiting the entire subroutine.
'For more details, open the "On Error statement" in the Designer help database Index.
Select Case Err
Case Else
'The next line will document an error, and will include the error number, the agent name,
'the line throwing the error, and the error description.
'The agent name is helpful if this is a web triggered or scheduled agent.
Msgbox "Error " & Cstr(Err) & " in " & thisAgent.Name & " on line " & Cstr(Erl) & ": " & Error
Resume Done
End Select
End Sub

Feedback number WEBBAU74BU created by on 04/22/2018

Go back