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
As a consumer of ZAbstractConnection I cannot prevent the exception of OnLostConnection from being raise, although I have a event handler to handle it. This forces me to handle the state of losing connection twice, first in the event handler and again in the function that led to this code path (handing the exception)
Can that be changes?
The following code is from the ZAbstractConnection unit
procedure TZAbstractConnection.ConnectionLost(var AError: EZSQLConnectionLost);
var Err: EZSQLConnectionLost;
begin
Err := AError;
AError := nil;
try
CloseAllLinkedComponents;
except end;
try
if Assigned(FOnLost) then
FOnLost(Self); { I think the Err variable should be passed here}
finally
if Err <> nil then
raise Err;
end;
end;
To be honest this code looks perfectly fine to me, I would not change it. Just do a check in your exception handler and if it's the connectionlost -> don't do anything.
Or remove your code from the OnConnectionLost handler.
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
Honestly I think that we could think about having a parameter like Handeled where true would indicate that everything is fine and we don't need to raise an exception and false means that we should raise an exception. Another option would be to name the paramaeter RaiseEcception and set it to rue by default...
But that is just an opinion. The decision is with Egonhugeist.
Serious question, what is the point of having an event handler if you *must* also catch the exception? everything I can do in the event handler I can do in exception handler but not vice versa.
stoffman wrote: ↑19.02.2021, 22:18Serious question, what is the point of having an event handler if you *must* also catch the exception? everything I can do in the event handler I can do in exception handler but not vice versa.
While I see your point (and it is perfectly valid I must add!) I always considered these event handlers as "notifications" for your program (so you can change an icon of a tabsheet, disable controls, etc.), the code flow is always Try .. Except .. End in my opinion. An exception is what Jan just mentioned - if you have a Var parameter to notify the component.
In 99% of the cases I'm creating Zeos's components runtime in worker threads and I design my program flow with exceptions included... therefore I never used ANY event handlers up until now.
The exception raised in the code is probably a part of the design as ANY workflow must be broken if the connection is broken.
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