Error Helper Functions
Helper functions are used to retrieve the localized error message string
from the resource file and should be defined for each category of error
exceptions that your application supports. For example, the Search functionality
may be represented by the following helper function:
Public Function SearchError(ByVal ErrorCode As Long,
ByVal e As Exception) As FnWSException
Dim msg As String
Dim aWSExcep as FnWSException
Select Case ErrorCode
Case FN_ERR_SEARCH.ContentValueNotValid
msg = rm.GetResourceString("FN_ERR_SEARCH_ContentValueNotValid")
Case FN_ERR_SEARCH.FileNotFound
msg = rm.GetResourceString("FN_ERR_SEARCH_FileNotFound")
Case FN_ERR_SEARCH.InvalidOpInXMLCommand
msg = rm.GetResourceString("FN_ERR_SEARCH_InvalidOpInXMLCommand")
Case FN_ERR_SEARCH.InvalidSearchTemplate
msg = rm.GetResourceString("FN_ERR_SEARCH_InvalidSearchTemplate")
Case FN_ERR_SEARCH.InvalidSystemType
msg = rm.GetResourceString("FN_ERR_SEARCH_InvalidSystemType")
Case FN_ERR_SEARCH.LibraryNotFound
...
Case Else
msg = rm.GetResourceString("FN_ERR_UnknownError")
End Select
If e Is Nothing Then
aWSExcep = New FnWSException(msg)
Else
aWSExcep = New FnWSException(msg,
e)
End If
aWSExcep.FnErrorCode = ErrorCode
Return aWSExcep
End Function
Public Function SearchError(ByVal ErrorCode As Long) As FnWSException
Return SearchError(ErrorCode, Nothing)
End Function
Use the helper function to throw a Search category error as follows:
Dim aErrObj as new FnUtil.FnError()
Throw aErrObj.SearchError(FN_ERR_SEARCH.FileNotFound, strLibName)
|