Hi,
If the server is not running how can I detect this in a VCL application that uses TXDataClient?
try except does not do work.
Thanks,
Ken
Hi,
If the server is not running how can I detect this in a VCL application that uses TXDataClient?
try except does not do work.
Thanks,
Ken
I can achieve this using Indy first:
idHTTP:=TIdHTTP.Create(Nil);
idHTTP.HTTPOptions:=idHTTP.HTTPOptions+[hoNoProtocolErrorException];
MS:=TStringStream.Create;
idHTTP.Get(TestURL,MS);
S:=Trim(MS.DataString);
MS.DisposeOf;
idHTTP.DisposeOf;
if S='' then it couldn't connect. Is there a way of doing this without having to use Indy?
Why try..except doesn't work?
The way to check it is simply trying to connect and then catch the exception is it raises.
This works:
HttpClient:=THTTPClient.Create;
try
HttpResponse:=HttpClient.Get(LiveURL+'/BGUsers/$count');
Contin:=HttpResponse.StatusCode=200;
except
Contin:=False;
end;
HttpClient.Free;
This does not:
try
XDataClient.Service<IAuthService>.Login(Username,Password);
except
Contin:=False;
end;
I get an EXDataOperationRequestError but have just realised what is wrong. I was running the debugger and it didn't know anything about that exception. Running normally works fine.