Sending specific agent errors to a mailbox instead of debugging

In order to get a better handle on application errors, SearchDomino.com member Yonit David built a script library that sends an e-mail to a specific mail database with the error information that can then be categorized by database. In this tip, he explains his logic and provides sample code.

In order to get a better handle on errors coming from applications for which I'm responsible, I built a script library with a function that sends an email to a specific mail database with the error information that I can categorize by database. I have the mail sent to a different mail database in production and development, so that it doesn't have to cross servers in development , so as to not bog down the production mail server if...

something is seriously wrong with an agent in development).

The address to the production mail database is "Agent Errors" and to production is "Development Errors" -- but these names can be changed to whatever you like. If five errors occur in one agent, it aborts the agent so that you don't send an unlimited amount of mail -- in case of infinite loops with errors. To use, include the Script Library and onError, and you can call the emailError function.

Code: 'Error_Handling' Option Public Dim errorCount As Integer Const errMsg="5 errors have already occurred from < name of Database> Database... Aborting" Const ERR_TOO_MANY_ERRORS_ABORT=1000 Sub Initialize errorCount=0 End Sub Sub emailError(strMethod As String, strErrorMsg As String, strLineNumber As String, refDoc As NotesDocument) %REM Sends out an email to the Agent Errors mailbox (Development Errors in development) in regards to an agent generated error. This should be called on Error in all lotusscript agents. Parameters String strMethod - Lotusscript Method that generated the error String strErrorMsg - The error message (pass error$) String strLineNumber - The line the error was generated on (pass Cstr(Erl)) NotesDocument refdoc - If there is a document that was being processed when the error is being generated. Pass that document here so it can be investigated for troubleshooting. %ENDREM Dim session As New NotesSession Dim db As notesDatabase Dim doc As notesDocument Dim rtItem As NotesRichTextItem Set db = session.currentdatabase Set doc = db.createdocument doc.Form = "Memo" If Instr(Lcase(db.Server),"put name of development server here")>0 Then doc.SendTo = "Development Errors" Else doc.SendTo = "Agent Errors" End If doc.Subject = "Error occured in " & strMethod & " on line " & strLineNumber doc.Principal = db.Title doc.OrigDatabase= db.Server & "" & db.Filepath doc.Method= strMethod Set rtItem=doc.CreateRichTextItem("Body") Call rtItem.AppendText(strErrorMsg) If Not(refDoc Is Nothing) Then Call rtItem.AddNewLine(2) Call rtItem.AppendText("Referring document: ") Call rtItem.AppendDocLink (refDoc,"Document that caused the error") End If Call doc.Send(False) errorCount=errorCount+1 If errorCount=5 Then Error ERR_TOO_MANY_ERRORS_ABORT, errMsg End If End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Yonit David. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was first published in February 2006

Dig deeper on Lotus Notes Domino Agents

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close