如何将 uniqueId 和 uniqueId 从 sub run 传递到 Sub DisplayCustomError。我试图通过 DisplayCustomError 但它给出“调用 Sub 时不能使用括号”。
预期结果:uniqueId 和 uniqueId 应该去 Sub DisplayCustomError 创建一个 json 对象。
sub run
On Error Resume Next
wrapper.getVariable( "IRR" ).value = excel.range( "'Cases'!$H$783" )
Dim uniqueId , uniqueId , errorMessage
If Err.Number <> 0 And excel.range( "'Cases'!$H$783" ) = "" Then
errorCode = "MC2006"
uniqueId = "12"
errorMessage= "Error while executing EVMLite.
DisplayCustomError(errorMessage)
On Error Goto 0
Call Err.Raise(vbObjectError + 10, "EVM Failed to execute. ", errorMessage)
End If
end sub
Sub DisplayCustomError(errorMessage)
If Err.Number <> 0 Then
Dim objHTTP, URL, json, uniqueId, networkInfo, jobId
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)
End If
结束子