PostSharp OnExceptionAspect not working as expected
Posted
by Rune Sundling
on Stack Overflow
See other posts from Stack Overflow
or by Rune Sundling
Published on 2009-07-16T13:31:51Z
Indexed on
2010/04/10
4:03 UTC
Read the original article
Hit count: 364
postsharp
Created a simple class to test out the OnExceptionAspect in PostSharp.
[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class ExceptionSwallower : OnExceptionAspect
{
public override void OnException(MethodExecutionEventArgs eventArgs)
{
eventArgs.FlowBehavior = FlowBehavior.Return;
base.OnException(eventArgs);
}
}
Added the attribute to a method
[ExceptionSwallower]
public void SomeMethod()
{
throw new Exception();
}
and invoked it.
However, the exception is not actually swallowed, which seems odd.
I haven't been able to find any similar problems, so I expect there is some minor thing I haven't gotten right. Anyone?
© Stack Overflow or respective owner