Monday, 10 December 2007

My on Error in LotusScript Agents


ExitNow:


Exit Sub

HandleError:

Dim strNewLineChar As String

Dim atkDb As NotesDatabase
Dim atkSession As New NotesSession()
Dim strErrMessage As String

strNewLineChar = Chr(13) + Chr(10)
If Not atkSession.CurrentAgent Is Nothing Then
strErrMessage = strErrMessage + "While running the agent named ["+_
atkSession.CurrentAgent.Name +"]" + strNewLineChar

strErrMessage = strErrMessage + " under the username ["+_
atkSession.CurrentAgent.OnBehalfOf +"]" + strNewLineChar

strNewLineChar = strNewLineChar + "
"

End If

strErrMessage = strErrMessage + "There has been an error encountered in the database with the title [" + _
atkSession.CurrentDatabase.Title + "]" + strNewLineChar + " on the server [" + _
atkSession.CurrentDatabase.Server + "] at the file location [" +_
atkSession.CurrentDatabase.FilePath + "]" + strNewLineChar

strErrMessage = strErrMessage + "The session username is ["+_
atkSession.username +"]" + strNewLineChar


strErrMessage = strErrMessage + "The error occurred at " + strNewLineChar + _
"Line number "+ Cstr(Erl) + strNewLineChar + _ ' Current line number (in the LS source)
"Function Name " + Lsi_info(2) + strNewLineChar + _ ' The current function or sub
"Module " + Lsi_info(3) + strNewLineChar + _ ' The current module
"Caller function: " + Lsi_info(12) + strNewLineChar +_ ' The name of the function that called this one, "the caller"
"The error code is " + Cstr(Err) + strNewLineChar +_
"The error message is " + Cstr(Error)


Print strErrMessage
Goto ExitNow
End Sub


This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.




NameDescriptionType
Err Numeric error code integer
Error Error text string
GetThreadInfo(LSI_THREAD_LINE) Current line number variant
GetThreadInfo(LSI_THREAD_PROC) Current procedure variant
GetThreadInfo(LSI_THREAD_MODULE) Current module variant*
GetThreadInfo(LSI_THREAD_VERSION) Lotusscript version variant
GetThreadInfo(LSI_THREAD_LANGUAGE) Language setting variant
GetThreadInfo(LSI_THREAD_COUNTRY) Country/Region setting variant
GetThreadInfo(LSI_THREAD_TICKS) Current clock ticks variant
GetThreadInfo(LSI_THREAD_TICKS_PER_SEC) Clock ticks per second variant
GetThreadInfo(LSI_THREAD_PROCESS_ID) Current process ID variant
GetThreadInfo(LSI_THREAD_TASK_ID) Current task ID variant
GetThreadInfo(LSI_THREAD_CALLPROC) Calling procedure variant
GetThreadInfo(LSI_THREAD_CALLMODULE) Calling module variant
Lsi_info(1) Current line number string
Lsi_info(2) Current procedure string
Lsi_info(3) Current module string
Lsi_info(6) Lotusscript version string
Lsi_info(9) Language setting string
Lsi_info(12) Calling procedure string
Lsi_info(50) LS memory allocated string
Lsi_info(51) OS memory allocated string
Lsi_info(52) LS blocks used string

* = this call returns a hex code, not the module name

Note:To use the GetThreadInfo constants, you must include LSPRVAL.LSS, which is automatically included through LSCONST.LSS

No comments: