Reference
You can develop an OnException aspect by deriving
the custom attribute OnExceptionAspect or by
implementing the interface IOnExceptionAspect.
Overview
The OnException aspect adds an exception handler to
the method to which it is applied. It allows you to easily
encapsulate exception handling policies as a custom attribute.
The method GetExceptionType
is invoked at compile-time. You can override it to specify the
types of exceptions that have to be caught by this handler. By
default, the handler will catch all exceptions.
The second important method is OnException.
It is the handler in itself. The current exception is available
from the Exception
property of the MethodExecutionEventArgs
object. This property is read-only. If you need to replace the
current exception by another one, you should throw a new exception
from the handler. If you need to ignore the exception, see the
section Changing the Control Flow in the discussion of the On Method Boundary aspect.