在vbscript中将stacktrace作为字符串

时间:2017-08-02 11:42:18

标签: excel-vba vbscript vba excel

我必须在错误和实际异常时捕获stacktrace。目前使用以下代码,每次在Call Err.Raise行显示抛出错误时,它就像行wrapper.getVariable("IRR").valuewrapper.getVariable("GT_Price").value

一样抛出错误
On Error Resume Next      
wrapper.getVariable("IRR").value = excel.range("'Cases'!$H$753")     
wrapper.getVariable("GT_Price").value = excel.range("'Cases'!$H$763")     

If Err.Number <> 0 Then
    Dim errorMessage, objHTTP, URL, json
    errorMessage ="Error while executing EVMLite. Error number " & Err.Number & ". " & Err.Description & " " & Err.Source
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")    
    URL = "http://10.93.24.223:9005/vpp/logerror"
    objHTTP.Open "POST", URL, False
    objHTTP.SetRequestHeader "Content-Type", "application/json"
    json = "{""jobId"": """& jobId &""", ""uniqueId"": """& uniqueId &""", ""errorCode"": """& errorCode &""", ""errorMessage"": """& errorMessage &"""}"
    objHTTP.send (json)
    On Error Goto 0
    Call Err.Raise(vbObjectError + 10, "EVM Failed to execute", errorMessage)
    'MsgBox objHTTP.ResponseText
End If

0 个答案:

没有答案