http://panther.sharedknowledgesystems.com:81/sharedknowledge/sksblog.nsf
04/07/2004 - Organizing Error Messages in LotusScript.

Permalink 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.



Comments

No documents found

Add Your Comments



Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-) :-D ;-) :-( :angry: :-o :grin: :cool: :laugh: :huh: :cry: :rolleyes: :-x :-p :-\ :emb: :lips:






Remember me    

Add Manual Trackback
Please enter the details of the trackback post. Your trackback will not appear on the site until it has been verified. This may take up to 10 minutes.

Site Name

Permanent URL of TrackBack Post

Title of Post ( If Any )

Excerpt of Post ( Max 250 Chars )



Calendar
February 2012
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29