I have a client/server app developed in delphi XE that uses TIdTcpClient
(Indy10) to communicate to each other.
All works fine most the time, the only issue is when I kill the server side the client is raising an exception that somehow raises all the way to the user, it first show my custom exception:
and after it display an error dialogue in blank as below:
This is the code that should override the original exception, the dialog I create display and the other dialog (the image above) display just after.
constructor EtvdNTierTcpException.Create(const AException: Exception);
const
error = 'error message';
var
AIdSocketError: EIdSocketError;
sMessage, sConnectionPoint: string;
begin
if AException is EIdSocketError then
begin
AIdSocketError := AException as EIdSocketError;
if StvdDefaultSession.tvdConnectionPoint = cpSqlProxy then
sConnectionPoint := FtvdNTierSqlProxy
else
sConnectionPoint := FtvdNTierSqlServer;
case AIdSocketError.LastError of
// 10054: Connection reset by peer
10054: self.Message := ExtractFileName(application.exename) + error + DateToStr(Now) + ' ' + TimeToStr(Now) + ' (' + AIdSocketError.ClassName + ')' + 'Connection for dataset fail at(10054)';
// 10061: Connection refused
10061: self.Message := ExtractFileName(application.exename) + error + DateToStr(Now) + ' ' + TimeToStr(Now) + ' (' + AIdSocketError.ClassName + ')' + 'Connection for dataset fail at(10061)';
else
self.Message := error + DateToStr(Now) + ' ' + TimeToStr(Now) + ' (' + AIdSocketError.ClassName + ')' + 'Connection for dataset fail at('+IntToStr(AIdSocketError.LastError)+')';
end;
end;
inherited;
end;
I try to use CheckForGraceFulDisconnect(false);
but it does not make any difference, any ideas in how to stop Indy displaying this error?
This is how the exception above get raised:
function TtvdNTierDataSet.tvdStmtExecute(const AStmt: string): Boolean;
begin
try
tvdStmtExecute := False;
// check we are still connected to the server
if tvdSession.tvdConnect then
begin
tvdStmtExecute := True;
// write the SQL Statement to the server
tvdWriteOutput;
end;
except
on E: Exception do
begin
// re-raise the exception
raise EtvdNTierTcpException.Create(E);
end;
end;
end;
if the exception is not of type EIdSocketError you get an empty Exception Dialog.