I am trying to make a package that can handle errors from methods by simply adding a [Attribute] above the method.
In my package I have
public class RequestLogFilter : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext filterContext)
{
Log(filterContext.Exception);
base.OnException(filterContext);
}
private void Log(Exception exception)
{
//log exception here..
}
}
When I try to use it in my MVC project
[RequestLogFilter]
public async Task<ActionResult> Index()
It says that Cannot access internal class here. My question is, is there some other decorator I should use besides ExceptionFilterAttribute? It says I need to reference System.Web.Http, but I don't have that in the references selection in my MVC project.
The goal is that if they call this type of filter It will log any exception to said filter.