Page 1 of 1

TZAbstractConnection.ConnectionLost issue

Posted: 14.09.2024, 18:26
by stoffman
In TZAbstractConnection.ConnectionLost the event is never considered to be raised i.e. EventErrorRaised is always False. It should be set under an else statement

https://github.com/frones/ZeosLib/blob/ ... .pas#L1032

p.s.
I think reordering the code would make it much more easier to reason about:

Code: Select all

EventErrorRaised = False
if Assigned(FOnLost) then begin
  EventErrorRaised := true;
  FOnLost(Self);
end;

Re: TZAbstractConnection.ConnectionLost issue

Posted: 14.09.2024, 20:59
by aehimself
It won't be false, if a custom exception is raised and handled WITHIN the event handler itself... like

Code: Select all

Procedure TConnection.OnLost(Sender: TObject);
Begin
  Raise Exception.Create('Connection to the database server was lost, please call 911');
End;
If no custom exception was raised we create and raise one at line 1048.

Re: TZAbstractConnection.ConnectionLost issue

Posted: 15.09.2024, 21:43
by stoffman
Thanks, I now understand the interface. connection lost will always raise an exception.