【发布时间】:2016-03-21 16:34:45
【问题描述】:
我有以下引发异常的函数:
procedure Test();
var
WinHttpReq: Variant;
begin
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
try
WinHttpReq.Open('POST', 'https://tv.eurosport.com/', False);
WinHttpReq.SetRequestHeader('Content-Type', 'application/json');
WinHttpReq.Send('');
except
MsgBox(GetExceptionMessage, mbError, MB_OK);
end;
end;
我想以整数形式获取错误,而不是在字符串GetExceptionMessage 中获取错误。
这可能吗?
【问题讨论】:
-
我想处理 SSL 证书错误,我认为依赖字符串作为常量是不好的做法。
-
如果没有办法得到错误码那我就靠字符串了。
-
例如:
if ErrorCode = SSL_CERTIFCATE_ERROR then doStuff()而不是if GetExceptionMessage = 'WinHttp.WinHttpRequest: the host name in the certificate is invalid or does not match' then doStuff()