An EIdHTTPProtocolException
exception is raised when TIdHTTP
successfully sends a request to the server and it sends an HTTP error reply back to TIdHTTP
. If the server cannot be reached at all, a different exception (typically EIdSocketError
, EIdConnectException
, or EIdConnectTimeout
) will be raised instead.
try
IdHTTP1.Head(mypage_address);
except
on E: EIdHTTPProtocolException do begin
ShowMessage(Format('HTTP Error: %d %s', [E.ErrorCode, E.Message]));
end;
on E: EIdConnectTimeout do begin
ShowMessage('Timeout trying to connect');
end;
on E: EIdSocketError do begin
ShowMessage(Format('Socket Error: %d %s', [E.LastError, E.Message]));
end;
on E: Exception do begin
ShowMessage(Format('Error: [%s] %s', [E.ClassName, E.Message]));
end;
end;