Organizing Error Messages in LotusScript.
Regardless of how you choose to handle errors, you can easily organize
your error messages for reuse and ease of localization.
I do this by creating an error message class in the declarations
section of a script library. Here is an extract from the error message
class in Calendar2Calendar:
Class qpErrorMsgs
Function GetErrorMsg (errorIndex As Integer) As String
Select Case errorIndex
Case QPDB_ERR:
GetErrorMsg="Could not locate the requested Team
WorkPlace."
Case NAB_ERR:
GetErrorMsg="The name of the Public Name &
Address book cannot be located. Please contact your Domino Administrator."
Case QPDELETE_ERR:
GetErrorMsg="This QuickPlace Calendar Entry could
not be removed: "
Case QP_MEETING_NOT_FOUND_ERR:
GetErrorMsg="This meeting could not be found
in the specified QuickPlace: "
Case QP_MEETING_SEARCH_ERR:
Case Else
GetErrorMsg="An unknown error has occurred."
End Select
End Function
End Class
The class qpErrorMsgs contains one function - GetErrorMsg
- which has one parameter, an error code. The function then returns a string
containing a description of the error. The error codes are constants, also
defined in the declaration of the same LotusScript library before the class
definition.
Const QPDB_ERR = 21
Const NAB_ERR = 24
Const QPDELETE_ERR=26
Const QP_MEETING_NOT_FOUND_ERR=27
Const QP_MEETING_SEARCH_ERR = 28
To use this class I define a variable as a new instance of the class in
script libraries, forms etc. with a Dim statement like this:
Dim calErr As New qpErrorMsgs
Then I need only call the function defined in the class when I want to
display an error message to the user.
Msgbox calErr.GetErrorMsg(QPDB_ERR)
I like organizing my error messages this way because I can use the same
error message over and over again with consistency of wording, without
duplicating the error string in the code, and in a way that gives me a
clear picture of all the errors I am actively managing. I also like this
method because I can export the code to an .lss file and translate the
error strings into several languages. This enables me to compile my code
for various languages by swapping in the appropriate .lss file using the
%Include directive.





-