When TIdHTTP
encounters a server error, it raises an EIdHTTPProtocolException
exception, where its ErrorCode
property contains the HTTP status code (500, etc), its Message
property contains the HTTP status text ("Internal Error", etc), and its ErrorMessage
property contains the body text of the response, if any. So, for example:
try
IdHTTP1.Get(...);
except
on E: EIdHTTPProtocolException do begin
// use E.ErrorCode, E.Message, and E.ErrorMessage as needed...
end;
end;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…