public void OnException(ExceptionContext context) { var ctx = new ExceptionResultContext { Exception = context.Exception, ExceptionContext = context, Request = context.HttpContext.Request, Response = context.HttpContext.Response, RequestServices = context.HttpContext.RequestServices, UserSession = context.HttpContext.RequestServices.GetService <IUserSession>() }; var rules = _exceptionResultConfig.Rules; IActionResult result = null; foreach (var rule in rules) { if (rule.When(ctx)) { result = rule.RespondWith(ctx); break; } } if (result != null) { context.Result = result; context.ExceptionHandled = true; } }
private static string BuildFormSummaryTag( string formSummaryId, MiruValidationException validationException, ExceptionResultContext m) { var formSummary = m.GetService <HtmlGenerator>() .FormSummaryFor(validationException.Model) .RemoveAttr("hidden"); // TODO: get from htmlconventions var turboStreamTag = new TurboStreamTag("replace", formSummaryId) .AppendIntoTemplate(formSummary); validationException.Errors.Each(error => formSummary.Add("div", tag => tag.Text(error.ErrorMessage))); return(turboStreamTag.ToString()); }
public static IFlashMessage Flash(this ExceptionResultContext ctx) => ctx.GetService <IFlashMessage>();
public static UserfyOptions UserfyOptions(this ExceptionResultContext ctx) => ctx.GetService <UserfyOptions>();
public abstract ActionResult Handle(ExceptionResultContext context);
public static CookieAuthenticationOptions CookieAuthenticationOptions(this ExceptionResultContext ctx) => ctx.GetService <IOptionsSnapshot <CookieAuthenticationOptions> >().Get(IdentityConstants.ApplicationScheme);