I am using the HTTP class to communicate to a web server. I use the following code and it works fine, except it the servername or port is incorrect it pops up a dialog box. I need to trap the error programmatically. Any suggestions?
Thanks
function TForm1.HttpGetInfo : Integer;
var
sErrVal : string;
iPos : byte;
strErr : string;
begin
try
strURLRtn := Http1.Get(strURL);
//Http1 declared elsewhere as Http1 : TiDHTTP;
except
on E:Exception do
begin
sErrMsg := E.Message;
strErr := E.Message;
strErr := Trim(strErr);
iPos := Pos(' ',strErr);
sErrVal := Copy(strErr,1,iPos-1);
Result := StrToInt(sErrVal);
//HandleError(E.Message, E.HelpContext);
Exit;
end;
end;
Result := 0;
end;
Thanks
function TForm1.HttpGetInfo : Integer;
var
sErrVal : string;
iPos : byte;
strErr : string;
begin
try
strURLRtn := Http1.Get(strURL);
//Http1 declared elsewhere as Http1 : TiDHTTP;
except
on E:Exception do
begin
sErrMsg := E.Message;
strErr := E.Message;
strErr := Trim(strErr);
iPos := Pos(' ',strErr);
sErrVal := Copy(strErr,1,iPos-1);
Result := StrToInt(sErrVal);
//HandleError(E.Message, E.HelpContext);
Exit;
end;
end;
Result := 0;
end;