Error handling 如何隐藏COM错误?

Error handling 如何隐藏COM错误?,error-handling,runtime-error,try-catch,autoit,suppress-warnings,Error Handling,Runtime Error,Try Catch,Autoit,Suppress Warnings,我的代码可以工作,但在WebRequest部分,如果系统脱机,则会出现错误: “无法解析此地址” WebRequest在存在internet连接时工作。我可以隐藏这个错误吗 #include <StringConstants.au3> #include <Array.au3> #include <String.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3>

我的代码可以工作,但在
WebRequest
部分,如果系统脱机,则会出现错误:

“无法解析此地址”

WebRequest在存在internet连接时工作。我可以隐藏这个错误吗

#include <StringConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <InetConstants.au3>
#include <WinAPIFiles.au3>

Opt("RunErrorsFatal", 0)

Global $eRRor = ObjEvent("AutoIt.Error","MyErrFunction")

Func MyErrFunction()
 ; empty function
Endfunc

...some code here...

$oweb = ObjCreate("winhttp.winhttprequest.5.1");
$oweb.Open("POST",$TheUrl , False); ;Error happens here
$oweb.SetRequestHeader("Content-Type", "application/(a type)");
$oweb.SetRequestHeader("User-Agent", "(a random user agent)");
$oweb.Send($content);

...other code...
但是如果错误(无声地)发生,我想继续

这是编译脚本(.exe文件)中的错误。第8047行的代码是
$oweb.Send($content)但在调试时启用了错误详细信息:


这发生在
$oweb.Open(“POST”,$TheUrl,False)

我错过了您已经使用的:

Global $eRRor = ObjEvent("AutoIt.Error","MyErrFunction")
只是莫迪菲

Func MyErrFunction($oError)
  ; do nothing
EndFunc

我错过了您已经使用的:

Global $eRRor = ObjEvent("AutoIt.Error","MyErrFunction")
只是莫迪菲

Func MyErrFunction($oError)
  ; do nothing
EndFunc

在使用对象之前检查internet连接是否处于活动状态是否有帮助。在使用对象之前检查internet连接是否处于活动状态是否有帮助。