There are two ways of handing of errors in the HTTP Client component.
1. You can set the SilentHTTP property to True and analyze the StatusCode property. This method allows you to get the server response in the provided destination stream:
clHttp.SilentHTTP := True;
clHttp.Get('http....', destination);
if (clHttp.StatusCode >= 400) then
//the destination parameter contains the server response
2. You can use the try-except blocks to handle the exception:
try
clHttp.Get('http....', destination);
except
on E: EclHttpError do
begin
E.ErrorCode...
E.ResponseText...
end;
on E: EclSocketError do
begin
E.ErrorCode...
end;
on E: Exception do
begin
//...other errors
end;
end;
Article ID: 106, Created: August 8, 2018 at 1:14 PM, Modified: August 8, 2018 at 1:16 PM