Open sandboxFocus

Class ExceptionAttribute

Binds a parameter of an OnMethodExceptionAdvice method to the exception thrown by the target method.

Inheritance
ExceptionAttribute
Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp.dll
Syntax
public sealed class ExceptionAttribute : AdviceParameterAttribute
Remarks

The parameter must be of type Exception, or of type object when it is passed by value.

When the parameter is passed by reference (ref or out), the advice can replace the exception. When the advice then sets ThrowException, the target method throws the exception that the parameter holds, as it throws Exception in an advice that receives MethodExecutionArgs. With Default or RethrowException, the original exception is rethrown, and the value of the parameter is ignored.

For an async method or an iterator, the value is the exception thrown by the code of the method, as Exception gives it.

Constructors

Name Description
ExceptionAttribute()

See Also