PostSharp 2023.0 / / Post­Sharp Documentation / API Reference / Post­Sharp.​Aspects Namespace / Method­Execution­Args Class / Method­Execution­Args Properties / Method­Execution­Args.​Exception Property

MethodExecutionArgs.Exception Property

Gets or sets the exception thrown by the target method.

Namespace:  PostSharp.Aspects
Assembly:  PostSharp (in PostSharp.dll) Version: 2023.0.3.0 (2023.0.3.0)
public Exception Exception { get; set; }

Property Value

Type: Exception
An Exception, or null if the method is exiting normally.

This property is only available inside the OnException(MethodExecutionArgs) and OnException(MethodExecutionArgs) advices.

You can replace the exception by setting this property and also setting FlowBehavior to ThrowException. You can also throw a new exception from the advice if you need to replace the current exception.

See Also