Unwrap ExceptionHandler

Topics: Development Team Discussion, User Discussion
Coordinator
Oct 21, 2007 at 7:17 PM
About to add an UnwrapExceptionHandler that basically rethrows the InnerException.

Quite useful when using reflection/ receiving TargetInvocationException

Any thoughts/concerns before I go on?
Developer
Oct 22, 2007 at 5:06 PM

How do you plan to use it? I often came upon such a behavior, and the thing is, you often need to handle the innerException in the same scope. That is:

try
{
}
catch (Exception ex)
{
ExceptionHandling.HandleException(ex, "myPolicy");
}

So, if in "myPolicy" you use the UnwrapExceptionHandler to throw the inner exception, you fall out of the scope of your catch. What I was thinking at the time, but never had the time to do, or look at, was that what we really need was some sort of policy-invoker exception handler. In that exception handler, you would be able to specify an exception policy to invoke with the inner exception.

To sum it up with your TargetInvocationException example:
1) You would first call a policy which would handle TargetInvocationException with a "PolicyInvokerExceptionHandler".
2) That policy-invoker handler would call another policy by passing it the inner exception.

The cases where I needed that behavior were for HttpUnhandledException and SoapException, but I never had the time to come back to it and do the handler.