I am trying to implement exception handling for Web Api using ExceptionFilterAttribute. I have inherited ExceptionFilterAttribute class and overridden the onException method.
public class ApiLogExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext actionExecutedContext)
{
if (actionExecutedContext != null)
{
Logger.LogException(actionExecutedContext.Exception);
}
}
}
Lately, I have seen some implementation where the base class OnException method is also called in the overridden implementation.
public class ApiLogExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext actionExecutedContext)
{
if (actionExecutedContext != null)
{
base.OnException(actionExecutedContext);
Logger.LogException(actionExecutedContext.Exception);
}
}
}
Which of the above two implementation is advisable? what is the use calling base method in this scenario?