Too many exception policies

Topics: Exception Handling Application Block, Logging Application Block
Oct 8, 2008 at 1:57 PM
I was curious if there was a good solution to this... if a developer has created lots and lots of policies in an attempt to create granular exception handling, is there a way to avoid having to configure every single policy? In this case it appears that enterprise library throws a configurationerrors exception when it cannot locate a policy named in the call to handleexception. In this particular case the developer has created around 30 named policies. It would be great if I could configure to handle specific policies but have a "catch-all" that could log any subsequent exceptions regardless of whether the policy was explicitly entered into the configuration. Otherwise, this could be a problem as the call to handleexception will raise an additional exception.
Oct 30, 2008 at 10:20 PM
Bump.. no one has a comment about this? Any info would be helpful. I'm just curious if I am missing something.
Oct 31, 2008 at 4:33 AM


You can try defining a single policy of type System.Exception with a Logging Handler.

The config looks like this.


      <add name="Default">


          <add type="System.Exception, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"

            postHandlingAction="ThrowNewException" name="Exception">


              <add logCategory="Exception Category" eventId="100" severity="Error"

                title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

                priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

                name="Logging Handler" />



And the code looks like this.




                    bool rethrow = ExceptionPolicy.HandleException(ex, "Default");

                    if (rethrow)





                catch (Exception exNew)








Hope this helps.




Oct 31, 2008 at 6:38 AM
I think the problem is the signature of HandleException requires that a string be supplied as the policy.. if that policy is missing.. game over... expect a crit exception for every call to handle exception .. regardless... I just don't think a lack of configuration should cause HandleException to throw the exception.. I think that is wrong. You should be able to have a default policy.. a catch all...