TZAbstractConnection.ConnectionLost issue

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
stoffman
Senior Boarder
Senior Boarder
Posts: 50
Joined: 03.12.2020, 06:55

TZAbstractConnection.ConnectionLost issue

Post 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;
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 796
Joined: 18.11.2018, 17:37
Location: Hungary

Re: TZAbstractConnection.ConnectionLost issue

Post 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.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
stoffman
Senior Boarder
Senior Boarder
Posts: 50
Joined: 03.12.2020, 06:55

Re: TZAbstractConnection.ConnectionLost issue

Post by stoffman »

Thanks, I now understand the interface. connection lost will always raise an exception.
Post Reply