Dynamically check if exception in exception filters

delphi package - automated exception handling
Post Reply
maggigisla
Posts: 10
Joined: Fri May 20, 2011 2:56 pm

Dynamically check if exception in exception filters

Post by maggigisla »

Hi ...
Is there a way for me to check if given exception that was raised is in the exception filters in the settings window ?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Dynamically check if exception in exception filters

Post by madshi »

You can use "exceptIntf.Filter1Classes" or "Filter2Classes" to ask the list of classes in the settings window. And you can use "exceptIntf.ExceptClass" to get the class name of the current exception. With all that information, you can simply check if the current exception class is listed in either Filter1Classes or Filter2Classes.
maggigisla
Posts: 10
Joined: Fri May 20, 2011 2:56 pm

Re: Dynamically check if exception in exception filters

Post by maggigisla »

Hi ...

I see the exceptIntf.ExceptClass property but not exceptIntf.Filter1Class or exceptIntf.Filter2Class, are they private ?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Dynamically check if exception in exception filters

Post by madshi »

Does the compiler complain?
maggigisla
Posts: 10
Joined: Fri May 20, 2011 2:56 pm

Re: Dynamically check if exception in exception filters

Post by maggigisla »

exceptIntf.Filter2Classes;
[dcc32 Error] main.pas(795): E2003 Undeclared identifier: 'Filter2Classes

Yes he does :)
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Dynamically check if exception in exception filters

Post by madshi »

Hmmmm, ok, then try using "MESettings().Filter2Classes" instead of "exceptIntf.Filter2Classes".
maggigisla
Posts: 10
Joined: Fri May 20, 2011 2:56 pm

Re: Dynamically check if exception in exception filters

Post by maggigisla »

Just to be sure that I'm not telling you some bullshit, I'll try to explain my situation again.
I'm inside the OnException event on TMadExceptionHandler.
In my case :
{code}
procedure TfrmMain.adalException(const exceptIntf: IMEException;
var handled: Boolean);
{code}

Here I want to check if the exceptIntf.ExceptClass is in either ExceptionFilter1 og ExceptionFilter2.
Properties Filter1Classes and Filter2Classes are not visible on variable exceptIntf.
Your suggestion to try MESettings() I don't understand, there's no property on the exceptIntf, so I'm not sure what you're telling me :)

Could you please clarify this for me :)
Thanks for quick responses and good service ...
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Dynamically check if exception in exception filters

Post by madshi »

I'm not sure I understand what you're asking. "MESettings().Filter2Classes" works fine for me. So what's the problem?
maggigisla
Posts: 10
Joined: Fri May 20, 2011 2:56 pm

Re: Dynamically check if exception in exception filters

Post by maggigisla »

In what scope is MESettings() a valid variable ?

[dcc32 Error] main.pas(795): E2003 Undeclared identifier: 'MESettings'
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Dynamically check if exception in exception filters

Post by madshi »

It's a function exported by madExcept.pas.
maggigisla
Posts: 10
Joined: Fri May 20, 2011 2:56 pm

Re: Dynamically check if exception in exception filters

Post by maggigisla »

:)
Now we are talking ..., that's what was missing, add madExecpt.pas to my uses clause ( I thought that madExceptVcl.pas was enough).
Thank you for your support
Post Reply