How to check if Exceptiod Handling Module is loaded

Topics: Exception Handling Application Block
Jan 23, 2009 at 1:14 PM
Hi,

 This is the usual sintax I use to work with:

catch(Exception ...)
bool rethrow = ExceptionPolicy.HandleException(sqlException, ExceptionPolicies.DALPolicy);
if (rethrow)
{
    throw;
}
}

What happenes is that when I run a test on my class I get ExceptionHandlingException. I suppose because I don't have the Module loaded of course.

Is there any way to test if the ExceptionPolicy is working before using it ?

Regards,
Calin


Jan 23, 2009 at 2:11 PM
Sorry but I don't quite understand what you mean.  What's the exact error message you're getting?
"Is there any way to test if the ExceptionPolicy is working before using it ?" - It works if it handles the exception the way you expected it to, could you explain what do you mean by this?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 23, 2009 at 3:39 PM
Hi,

 Sorry for being unclear I was in a hury.

 What I mean is that:

 bool rethrow = ExceptionPolicy.HandleException(sqlException, ExceptionPolicies.DALPolicy);

 this line will throw ExceptionHandlingException

 I know this happenes because EntLib failed to read the app.config file. So what I need I some mechanism to check if ExceptionHandling block was initializade correcly.

 Hope this makes it clear.

Regards,
Calin
Jan 23, 2009 at 5:29 PM

Hi,

would you mind posting your full exception? also if you can post your config and your code snippet.


Valiant Dudan
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 24, 2009 at 4:10 AM
You can use this..

SystemConfigurationSource s = new SystemConfigurationSource();
ConfigurationSection exceptionHandlingSection = s.GetSection("exceptionHandling");

If exceptionHandlingSection is null, then either the configuration file is not present or there was no exception handling section in the config file.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Jan 24, 2009 at 6:09 AM
Hi Sarah

 Thank you, that was exacly what I was looking for. I was hoping for something like bool ExceptionPolicy.Avalible but testing the config file makes sense.

Regards,