Table of contents
When developing a Web site, you have a different way of troubleshooting problems. Unless you are a person who never writes code that could possibly fail and you have users that never do anything wrong, plan for errors. Some of the error handling is done in your code, such as field validation, and some is done by the server, such as authentication.
For troubleshooting errors, you have to resort to the server logs and some preventive coding. The server's log (log.nsf) show errors that the server detects, but it is hard to match them up. The Web server log (domlog.nsf) shows the URl that was entered and the resulting error message.
With the Notes Client, you can step through LotusScript, pop-up messages, and look at the document properties. Also the Notes Client can handle some errors like mismatched field types with just a dialog box. On the Web, this is all up to you. You can't step through the code. You can't look at the document properties. All you get is a 500 or 400 error page. You have to design the page and site with error handling in mind.
You sometimes use WebQueryOpen, WebQueryClose and plain agents to process the data for the Web pages. Since you can't step through the agents by using the LotusScript debugger, you must resort to other means. Since you are working with the browser, you can't use the print statement because it sends the data to the browser. You can use a feature of Notes, the agentlog. The template for the log (alog.ntf) is on the server. You only need to create the database and use the Notes classes to write to it.
On Error Goto ErrorHandler
'set to False to turn logging off
Const LOG_ON = True
Const LOG_VERBOSE = False
Dim agentLog As New NotesLog(s.CurrentDatabase.Title&" - "& s.CurrentAgent.Name)
Call agentLog.OpenNotesLog( "", "AgentLog.nsf" )
If LOG_ON Then Call agentLog.LogAction("Agent Started" )
'**     agent code goes here     **
If LOG_VERBOSE Then Call agentLog.LogAction("Updated records")
If LOG_ON then Call agentLog.LogError( Err, Error$_
& "    Line#: "   &  Erl & |   Object: | & Lsi_info(2)  )
If LOG_ON Then
Call agentLog.LogAction( "Agent Finished" )
The constants, LOG_ON and LOG_VERBOSE are used to enable logging and to allow for verbose reporting that is helpful for troubleshooting.
Now you can put lines in to capture data as the agent is executing. When you done with development, set the LOG_VERBOSE to false and only the errors and agent info are captured. It's helpful to look at the log and see when an agent stopped working.
The biggest source of errors here are mismatched field types and the dblookup/dbcolumn. For dblookup and dbcolumn, always check for an error in the return value. There is always the chance that someone deletes the keyword document or changes the key name.
ClassCache := "Notes":"Cache";
LookupDb := "REPID";
View := "Keywords";
Key := "DEPT";
Column := 2;
Temp := @DbLookup(ClassCache; LookupDb; View; Key; Column);
@If(@IsError(Temp); "N/A"; Temp)
For mismatched fields, you check the type before using it. These are normally from old data that has not been migrated correctly or an error in coding on another form or agent.
Authentication, authorization, and general errors can be handled on a Web site or individual database basis. If there is error handling in the database, it's used otherwise the configuration in the Domino Web Configuration database is used for error handling. This can be set up by Web site or server. For information about the Domino Web Configuration database, see the 6.0 Server configuration
This handling of errors is for database usage only. Missing files on the server hard drive still cause a 404 error. You can setup an error.html pages on the server to handle these errors. This is described further in 6.0 Server configuration.
Database specific error pages
You can have forms or pages in your database handle the general errors. This way you can try to help the user correct their problem. If you build your own form, you can add a field called MessageString, which shows the reason for the error. By creating a form or page with a special name, you can catch the error.
Form or page name
User failed to be authenticate with the server
User does not have enough access rights
The document has been successfully deleted
Catch all for the rest of the errors, usually it's a design element not found
By adding a field called MessageString
to your form, it displays the reason for the error, which could be used to give the user additional help. For example, if a user is looking for a job posting, you can tell them it's no longer there and let them search for other jobs.
For more information, see the Designer Help database. A sample of each of these forms is in the Riverbend sample database.