tags:

views:

218

answers:

2

Hi,

I have read several documentations about building custom ErrorHandler (by inheriting from IErrorHandler). Unfortunately, I have several doubts about how doing it.

The problem is that I don't exactly understand the meaning of the two methods of IErorrHandler (i.e. ProvideFault and HandleError). For me, the HandleError is used to process asynchronous logic (e.g. login). But, in this case, why does this method return a boolean? I also think that the other method can be used to determine whether an error should be propagated to the client or to something else.

Am I wrong ?

+2  A: 

Based on the MSDN documentation, the boolean is to return a success or failure of performing the needed behavior.

You are correct in that the ProviderFault method is where you control what is returned to the client.

I highly recommend reading the linked MSDN doc, it provides some good insight.

Mitchel Sellers
A: 

I had implemented a handler at one point to do logging of exceptions in the HandleError() and to do Exception-to-Fault translations in the ProvideFault(). This worked fairly well for me for awhile.

However I have since stopped using the IErrorHandler as I found that it wouldn't get fired on all exceptions. I believe that it was a System.Security.SecurityException that was passing through that wouldn't get caught by this code. It was like WCF special cased it and just passed it straight to the client. This made me a bit nervous as I started wondering what else I wasn't catching in this supposedly catch-all interface.

Kyle