I want to register Custom Exception filter using Composer in Umbraco 8. Help on this is greatly appreciate.
public class Global : UmbracoApplication, IComposer
{
public void Compose(Composition composition)
{
// want to register custom exception filter here
}
}
Custom filter
public class MyExceptionFilter : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext exceptionContext)
{
if (!exceptionContext.ExceptionHandled && exceptionContext.Exception is NullReferenceException)
{
exceptionContext.Result = new RedirectResult("Error.html");
exceptionContext.ExceptionHandled = true;
}
else
{
var exceptionDetails = new
{
ApplicationName = Constants.FirstAgencyWeb,
Controller = exceptionContext.RouteData.Values["controller"],
Action = exceptionContext.RouteData.Values["action"],
ErrorMessage = exceptionContext.Exception.InnerException,
ErrorStackTrace = exceptionContext.Exception.StackTrace
};
Log.Logger.Error("Error {@Detials}", exceptionDetails);
}
}
}
how to register mvc Exception filter using Composing in Umbraco 8
Hi,
I want to register Custom Exception filter using Composer in Umbraco 8. Help on this is greatly appreciate.
Custom filter
A bit late but maybe this can help somebody else. Try
Check here for more info.
is working on a reply...