【发布时间】:2015-06-12 05:24:07
【问题描述】:
如果返回 404 页面未找到,我如何让 Idhttp 循环运行 问题是 'GOTO CheckAgain' 导致进入或退出 TRY 语句
label
CheckAgain;
begin
CheckAgain:
try
idhttp.Get(sURL+WebFile[I], S);
except
on E: EIdHTTPProtocolException do
if AnsiPos('404',E.Message) <> 0 then
begin
I := I+1;
goto CheckAgain;
end;
end;
end;
【问题讨论】:
-
while True do if ItsTimeToStop then Break;,或者只是while WantToTryAgain do Something;不解析异常消息;EIdHTTPProtocolException异常有ErrorCode成员。 -
@TLama 谢谢
while WantToTryAgain do Something工作得很好,关于异常消息EIdHTTPProtocolException我不明白 -
我的意思是你的代码上下文中的
E变量也有包含(已经解析的)错误代码的ErrorCode成员。您可能会发现更多关于它的信息,例如在this thread.