Problem with how exceptions are handled in ZIBEventAlerter

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
MerijnB
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 10.03.2009, 10:31
Location: The Netherlands
Contact:

Problem with how exceptions are handled in ZIBEventAlerter

Post by MerijnB »

In ZIBEventAlerter.pas, there is a routing called HandleException(). It's called in the Execute() method as well as in the destructor. HandleException() will indirectly show all exceptions using SysUtils.ShowException (via DoHandleException).

All in all it results in the following problem for me:

Code: Select all

 try
  fEventAlerter.UnRegisterEvents();
 except
  // I want to silently ignore
  // all exceptions, but I can't
 end;
It's not possible to call UnRegisterEvents and ignore any exceptions which are raised, because DoHandleException will show all of them anyhow.
Can somebody tell me what I'm missing here, or could I make a patch for this, if yes, what would be the preferred way?

tia,

Merijn
- A software developer is somebody who looks both left and right before crossing a one-way street.
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

At this sight I'd add a new property like this:

TZIBEventAlerter = class(TComponent)
private
FSilentlyUnRegister : boolean;
...
published
property SilentlyUnRegister: boolean read FSilentlyUnRegister write FSilentlyUnRegister;

constructor TZIBEventAlerter.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FSilentlyUnRegister := false;
...
end;

function TIBEventThread.HandleException: boolean;
begin
if (not Parent.ThreadException) and (not SilentlyUnRegister) then
begin
Result := True;
Parent.ThreadException := True;
FExceptObject := ExceptObject;
FExceptAddr := ExceptAddr;
try
if not (FExceptObject is EAbort) then
Synchronize(DoHandleException);
finally
FExceptObject := nil;
FExceptAddr := nil;
end;
end
else
Result := False;
end;
MerijnB
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 10.03.2009, 10:31
Location: The Netherlands
Contact:

Post by MerijnB »

Hi seawolf, thanks for your reply.

That's very much like what I had in mind, but I'm a little reluctant since I can't see the point of the way things are currently done, I was hoping to get some insight in that before making any changes.
- A software developer is somebody who looks both left and right before crossing a one-way street.
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

My personal opinion is that the developer would to know if an exception was raised, but doing this

SysUtils.ShowException(FExceptObject, FExceptAddr);

every exception is show .. but in a productivity software could be not a good idea show the exception
MerijnB
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 10.03.2009, 10:31
Location: The Netherlands
Contact:

Post by MerijnB »

If that is the only reason and there is no additional functionality there which is used, I'd like to opt to remove it completely.
If you don't catch the exception it's shown automatically, and if you do catch it you do it to avoid it's being shown.

This construction is really quite confusing imho.

Anyone against ripping it out all together?
- A software developer is somebody who looks both left and right before crossing a one-way street.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

MerijnB,

It seems like you can go on. I think it's even a patch that should be accepted in 6.6-patches branch.

Do you drop your changes here or at z e o s l i b <at> g m a i l <dot> c o m?

Mark
Image
MerijnB
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 10.03.2009, 10:31
Location: The Netherlands
Contact:

Post by MerijnB »

Hi mdaems, thanks for your reply.

I'll make the changes and drop them here (in the patches sub forum), not sure when yet, a little busy with other stuff atm.
- A software developer is somebody who looks both left and right before crossing a one-way street.
Post Reply