try body:=IdHTTP1.Get('http://site.com/script.php'); except on EIdHTTPProtocolException do begin //Твой код end; end;