Page 1 of 1

Problem with how exceptions are handled in ZIBEventAlerter

Posted: 25.03.2009, 16:14
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

Posted: 25.03.2009, 22:19
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;

Posted: 25.03.2009, 22:28
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.

Posted: 25.03.2009, 22:59
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

Posted: 26.03.2009, 07:35
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?

Posted: 02.04.2009, 21:55
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

Posted: 03.04.2009, 08:31
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.