Page 1 of 1

Dynamically check if exception in exception filters

PostPosted: Thu Mar 30, 2017 6:28 pm
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 ?

Re: Dynamically check if exception in exception filters

PostPosted: Thu Mar 30, 2017 6:38 pm
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.

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 12:50 pm
by maggigisla
Hi ...

I see the exceptIntf.ExceptClass property but not exceptIntf.Filter1Class or exceptIntf.Filter2Class, are they private ?

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 12:58 pm
by madshi
Does the compiler complain?

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 1:31 pm
by maggigisla
exceptIntf.Filter2Classes;
[dcc32 Error] main.pas(795): E2003 Undeclared identifier: 'Filter2Classes

Yes he does :)

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 1:45 pm
by madshi
Hmmmm, ok, then try using "MESettings().Filter2Classes" instead of "exceptIntf.Filter2Classes".

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 1:52 pm
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 ...

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 2:03 pm
by madshi
I'm not sure I understand what you're asking. "MESettings().Filter2Classes" works fine for me. So what's the problem?

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 2:07 pm
by maggigisla
In what scope is MESettings() a valid variable ?

[dcc32 Error] main.pas(795): E2003 Undeclared identifier: 'MESettings'

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 2:17 pm
by madshi
It's a function exported by madExcept.pas.

Re: Dynamically check if exception in exception filters

PostPosted: Fri Mar 31, 2017 2:32 pm
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