WCF, EHAP and Inner Exceptions

Topics: Exception Handling Application Block
Oct 10, 2008 at 8:11 PM
I have a multi-layer application that exposes WCF services.

Each layer in the app uses an EHAP policy to Wrap the exception into a new more generic exception for that layer, ie. BusinessLayerException or DataAccessLayerException.

So, if an invalid argument exception is thrown in the DataAccessLayer, it would be wrapped inside a DataAccessLayerException object.

When it propagates through the WCF service, the client receives one of 2 things:

If includeExceptionDetailInFaults=true

or, if
includeExceptionDetailInFaults=false, it uses my FaultContract and returns a custom ServiceFault object, as defined by me and populated by EHAP FaultContractExceptionHandler for Exception shielding.

In either case, the Message comes from the parent (outer most) exception object.

What is the best way to enable a DEBUG flag that would also include the InnerException chain returned to the client?  In either case above, the InnerException chain is never included, so the true error (InvalidArgumentException) would always be hidden.

Thanks in advance.