Multiple Exception Handlers for one exception type

Posted by danish on Stack Overflow See other posts from Stack Overflow or by danish
Published on 2010-03-28T06:33:28Z Indexed on 2010/03/28 6:43 UTC
Read the original article Hit count: 1326

I am using Enterprose Library 4.1. I have created a custom exception handler called CustomHandler. This is how the configuration section would look like:

      <add name="Exception Policy">
          <add type="System.Exception, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow" name="Exception">
              <add type="WindowsFormsApplication1.CustomHandler, WindowsFormsApplication1"
                name="Custom Handler" />
              <add exceptionMessage="Some test mesage." exceptionMessageResourceName=""
                exceptionMessageResourceType="" replaceExceptionType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingException, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                name="Replace Handler" />

There are two handlers for same exception type. What I want is that based on a certain condition one of the handlers should handle the exception. Any ideas how that can be done?

Is there a way to call the other handler from inside the HandleException method of the custom handler based on some condition?

© Stack Overflow or respective owner

Related posts about c#

Related posts about exception-handling