Exception Shielding Handling generic FaultException

May 11, 2007 at 3:09 PM
Edited May 11, 2007 at 7:08 PM
(I HAVE MOVE THIS DISCUSSION TO THE PATTERN AND PRACTICE – ENTERPRISE LIBRARY PROJECT)

Hello!

I have an architecture with multiple logic layers that communicates together through WCF services and I use the Exception Shielding pattern to manage the exception handling.

Let's say I have a client that calls a service on layer A and that service calls another service on layer B. The layer B fails for any reason and the exception is correctly managed by its own exception Shielding. So the Service on layer B returns an appropriate System.ServiceModel.FaultException<FaultContractB> to the service on layer A. I don't want the service on layer A to catch the System.ServiceModel.FaultException<FaultContractB>, I wan't the exception Shielding on the Layer A to manage this. My problem is that the Exception Shielding catches a simple System.ServiceModel.FaultException (not the generic System.ServiceModel.FaultException'1 type)...

Now let's say I have two distinct type of FaultException on layer B (how about FaultContractB1 and FaultContractB2). How will the Layer A be able to distinct them if the Exception Shielding handles the same type(System.ServiceModel.FaultException) for both?

I'm afraid that I will have to catch each of the FaultException Type on the Layer A, and throw new custom exceptions that will correspond to each of these types.

Am I missing something?

Thank you!