I am new at using exceptionfilters.
Following the link: https://learn.microsoft.com/en-us/aspnet/web-api/overview/error-handling/exception-handling#httpresponserexception
I've created a class
public class NotImplExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
if (context.Exception is NotImplementedException)
{
context.Response = new HttpResponseMessage(HttpStatusCode.NotImplemented);
}
}
}
then i used the attribute on a single method on my controller. i did not add the filter globally yet because i want it to work on a single method for now.
public class HomeController : Controller
{
[NotImplExceptionFilter]
public void Test()
{
throw new NotImplementedException("This method is not implemented");
}
}
But the OnExepction is not being called every time i'm throwing an error. please let me know what am i missing