PDA

View Full Version : ThrowsAdviceInterceptor rethrows the exception


cuader
06-29-2006, 07:18 PM
Hello, i wish to know if is correct this behavior. :confused:
I implement a IThrowsAdvice to handle Exception this works well, but when the ejecution control leave my advice the ThrowsAdviceInterceptor rethrow the exception that i have before handle.
I will like that exception don't be rethrown.

this is the code of the Spring.net framework where this happen:
public sealed class ThrowsAdviceInterceptor : IMethodInterceptor
....

public object Invoke(IMethodInvocation invocation)
{
try
{
return invocation.Proceed();
}
catch (TargetInvocationException ex)
{
// bah, this is a tad gross...
Exception realException = ex.InnerException;
LookupAndInvokeAnyHandler(realException, invocation);
throw realException;
}
catch (Exception ex)
{
LookupAndInvokeAnyHandler(ex, invocation);
throw ex;
}
}

I mark in bold the line where i think is the bug.

It' is right?

Txs :-D

Bruno Baia
06-30-2006, 01:40 PM
Hi,

Can you post your code to see how you are using it.

Thks,
Bruno