我们在捕获Idhttp的错误信息的时候通常只能捕获到类似http1.1 403 Error的信息,而在IE中有时可以显示友好HTTP错误信息,跟踪发现Idhttp在输出exception.message时,只取了错误信息的第一行信息,而把后面的内容都删除掉了。其实后面的信息并没有被完全抛掉,而是存在了EIdHTTPProtocolException的ErrorMessage中,我们通过此字段可以获得。示例代码如下:
try
FIdhttp.Get('http://www.prize8.com', newHtmlStream);
except
on e: Exception do begin
if e is EIdHTTPProtocolException then begin
FLogStr := (e as EIdHTTPProtocolException).ErrorMessage;
end;
end;
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.095675945281982 seconds