Create custome Handler with exception application block

Topics: Exception Handling Application Block
Feb 8, 2010 at 8:19 AM

Hi,

I'm using the WCF Exception Shielding ability for converting an exception to fault exception before I return it to the client.

I want to create for this policy, a custom handler, that will log(using my code) the original exception before the convertion.

My code is:

 [ConfigurationElementType(typeof(CustomHandlerData))]

    public class myExceptionLoggingHandler : IExceptionHandler

    {

        public myExceptionLoggingHandler(NameValueCollection collection)

        {

         }

        public System.Exception HandleException(System.Exception exception, Guid handlingInstanceId)

        {

 

//here I want to use my code to log the original exception that was raised (not the fault exception)

           

            return exception;

        }

    }

 

 If I insert to my configuration, the custome handler before the Fault Contract Exception Handler, I'm getting only the original exception. If I insert to my configuration, the custome handler after the Fault Contract Exception Handler, I'm getting only the fault exception.

Can I get both of the exceptions in one handler?

 

Thanks,

Avi

Feb 8, 2010 at 8:24 AM

Let me ask this first, do you really need a custom logging handler?  What specifically do you want to achieve by obtaining both exceptions in your custom handler?

 

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