Home > Domino Tips > Developer > Agent > Sending specific agent errors to a mailbox instead of debugging
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

AGENT

Sending specific agent errors to a mailbox instead of debugging


Yonit David
02.14.2006
Rating: -3.64- (out of 5) Hall of fame tip of the month winner


Lotus Notes, Domino, Workplace and WebSphere tips and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Agent
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax
How to automatically create a backup copy of your Domino Directory
Export Lotus Notes documents to Microsoft Word via Internet Explorer
A bevy of Notes/Domino development tips
Best practices for using the Lotus Notes WebQuerySave agent
A flexible data export agent for Lotus Notes

Lotus Notes Domino Agents
Verify scheduled agent status with Domino Extensible Language (DXL)
Top 10 Lotus Notes Domino programming and development tips of 2007
How to export data from a Lotus Notes database to a CSV file
Must-know Lotus Notes Domino agents -- 10 tips in 10 minutes
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax
Troubleshooting a scheduled agent not running on a Global Notes Architecture (GNA) server
Can I stop Lotus Domino Server from transforming embedded images into attachments?
How to automatically create a backup copy of your Domino Directory

Lotus Notes Domino Data Management and Storage
How and why to change replica IDs during a Lotus Notes Domino upgrade
How to fix the Lotus Notes unread documents feature
Pen testing your VPN
VPN clients for mobile devices
Top 10 best practices for e-mail archiving
Analysis: Will IBM buy BI?
Application for queueing non-delivery reports on hub mail server
Create print preview button, save paper when printing in iNotes
Can Domino collect mail from Web, then distribute to LAN Notes clients?
'Young' servers could lead to spending freeze

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts