Hi,
I have a question regarding raising erorrs. I have a piece of code which tries to do a HTTPRequest. If the request returns an error code I raise a specific error.
when I test this prior to complilation the err.number appears to be correct, but my err.description appears to ne over written.
When I compile and test both the err.number and err.description are overwritten.
All the work is done within one method so the err values should not be reset. Can soeone explain what is going on here??
Public Function doSearch(ByVal regMark As String, ByVal enqDate As String) As String
Dim xmlrequest As String
Dim httprequest As New MSXML2.XMLHTTP26
Dim searchString As String
Dim resultString As String
On Error GoTo searchErr
' Check parameter length
If (Len(regMark) = 0) Then
Err.Raise TRADS_EXPERIAN_ZERO_LENGTH_REGMANRK_PARAM_NUM, "Trads_POC:Experian " & TRADS_EXPERIAN_ZERO_LENGTH_REGMANRK_PARAM_DESC
End If
' Check parameter length
If (Len(enqDate) = 0) Then
Err.Raise TRADS_EXPERIAN_ZERO_LENGTH_ENQDATE_PARAM_NUM, , TRADS_EXPERIAN_ZERO_LENGTH_ENQDATE_PARAM_DESC
End If
enqDate = Format(enqDate, "yyyymmdd"
' Build the search string to submit via get
searchString = EXPERIAN_URL + enqDate + EXPERIAN_REGMARK_PARAM + regMark
' Build the request object details and submit to servlet on client
httprequest.open "GET", searchString, False
httprequest.send
' Wait for the connection to indicate that the response is ready
Do While (httprequest.readyState <> iRESPONSEREADY)
DoEvents
Loop
' Check for a valid response
If Not (httprequest.Status = EXPERIAN_RESPONSE_OK) Then
Err.Raise TRADS_CONNECTION_FAILED_ERROR_NUM, "Trads_POC:Experian" & TRADS_CONNECTION_FAILED_ERROR_DESC
End If
' Return result as XML string
doSearch = httprequest.responseText
exitProc:
Exit Function
searchErr:
'write the error to the log, and raise the error to the client
Call App.LogEvent("Error " & Err.Number & ":" & Err.Description & " in Experian: doSearch Method", vbLogEventTypeError)
doSearch = "Error " & Err.Number & ":" & TRADS_CONNECTION_FAILED_ERROR_DESC & " in Experian: doSearch Method"
End Function
I have a question regarding raising erorrs. I have a piece of code which tries to do a HTTPRequest. If the request returns an error code I raise a specific error.
when I test this prior to complilation the err.number appears to be correct, but my err.description appears to ne over written.
When I compile and test both the err.number and err.description are overwritten.
All the work is done within one method so the err values should not be reset. Can soeone explain what is going on here??
Public Function doSearch(ByVal regMark As String, ByVal enqDate As String) As String
Dim xmlrequest As String
Dim httprequest As New MSXML2.XMLHTTP26
Dim searchString As String
Dim resultString As String
On Error GoTo searchErr
' Check parameter length
If (Len(regMark) = 0) Then
Err.Raise TRADS_EXPERIAN_ZERO_LENGTH_REGMANRK_PARAM_NUM, "Trads_POC:Experian " & TRADS_EXPERIAN_ZERO_LENGTH_REGMANRK_PARAM_DESC
End If
' Check parameter length
If (Len(enqDate) = 0) Then
Err.Raise TRADS_EXPERIAN_ZERO_LENGTH_ENQDATE_PARAM_NUM, , TRADS_EXPERIAN_ZERO_LENGTH_ENQDATE_PARAM_DESC
End If
enqDate = Format(enqDate, "yyyymmdd"
' Build the search string to submit via get
searchString = EXPERIAN_URL + enqDate + EXPERIAN_REGMARK_PARAM + regMark
' Build the request object details and submit to servlet on client
httprequest.open "GET", searchString, False
httprequest.send
' Wait for the connection to indicate that the response is ready
Do While (httprequest.readyState <> iRESPONSEREADY)
DoEvents
Loop
' Check for a valid response
If Not (httprequest.Status = EXPERIAN_RESPONSE_OK) Then
Err.Raise TRADS_CONNECTION_FAILED_ERROR_NUM, "Trads_POC:Experian" & TRADS_CONNECTION_FAILED_ERROR_DESC
End If
' Return result as XML string
doSearch = httprequest.responseText
exitProc:
Exit Function
searchErr:
'write the error to the log, and raise the error to the client
Call App.LogEvent("Error " & Err.Number & ":" & Err.Description & " in Experian: doSearch Method", vbLogEventTypeError)
doSearch = "Error " & Err.Number & ":" & TRADS_CONNECTION_FAILED_ERROR_DESC & " in Experian: doSearch Method"
End Function