WCF ErrorHandler

后端 未结 2 1302
心在旅途
心在旅途 2021-01-27 09:05

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

The pr

相关标签:
2条回答
  • 2021-01-27 09:47

    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.

    0 讨论(0)
  • 2021-01-27 09:51

    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.

    0 讨论(0)
提交回复
热议问题