public override void OnException(ExceptionContext context) { if (context.Exception.GetType() == typeof(InvalidOperationException)) { context.Result = Helpers.GetContentResult(context.Result, "Action Exception Filter"); } }
public void OnException(ExceptionContext context) { var httpContext = context.HttpContext; if (httpContext.Response.HasStarted) return; if (context.Exception is CommonException) { _page.SetException(context.Exception); WritePage(httpContext, _page.Render().Replace(@"/", string.Empty)); } else if (context.Exception is ArgumentNullException || context.Exception is FormatException) { var page = SetupPage(httpContext, _page, context.Exception, 400); WritePage(httpContext, page); } else if (context.Exception is SqlException) { var page = SetupPage(httpContext, _page, context.Exception, 503); WritePage(httpContext, page); _logger.LogError(context.Exception.HResult, context.Exception.Message, context.Exception); } else { httpContext.Response.StatusCode = 503; _logger.LogError(context.Exception.HResult, context.Exception.Message, context.Exception); } }
public void OnException(ExceptionContext context) { var httpContext = context.HttpContext; if (httpContext.Response.HasStarted) return; if (context.Exception is ArgumentNullException || context.Exception is FormatException) { var page = SetupPage(httpContext, _page, context.Exception, 400); WritePage(httpContext, page); } else if (context.Exception is InvalidUserException) { var page = SetupPage(httpContext, _page, context.Exception, 401); WritePage(httpContext, page); } else if (context.Exception is SqlException) { var page = SetupPage(httpContext, _page, context.Exception, 503); WritePage(httpContext, page); _logger.LogError(context.Exception.HResult, context.Exception.Message, context.Exception); } else { httpContext.Response.StatusCode = 503; _logger.LogError(context.Exception.HResult, context.Exception.Message, context.Exception); } }
//public override Task OnExceptionAsync(ExceptionContext context) //{ // _logger.LogInformation("OnActionExecuting async"); // return base.OnExceptionAsync(context); //} private void handleCustomException(ExceptionContext context) { if (context.Exception.GetType() == typeof(CustomException)) { _logger.LogInformation("Handling the custom exception here, will not pass it on to further exception filters"); context.Exception = null; } }
public void OnException(ExceptionContext context) { context.Result = new TwilioResponseResult(x => { x.AliceSay("Sorry, an error occurred."); x.Redirect(TwilioVoiceRoutes.MainMenu, "get"); }); }
public virtual Task OnExceptionAsync(ExceptionContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } OnException(context); return TaskCache.CompletedTask; }
public override void OnException(ExceptionContext context) { _errorLogger.Log(context.HttpContext.Request, context.Exception); base.OnException(context); }
public override void OnException(ExceptionContext context) { context.Exception = null; }
public override void OnException(ExceptionContext context) { throw new InvalidProgramException("Exception Filter threw"); }
public virtual void OnException([NotNull] ExceptionContext context) { }
public void OnException(ExceptionContext context) { _logger.LogInformation("OnException"); }
public void OnException(ExceptionContext context) { _request.Finish(true); throw context.Exception; }
public void OnException(ExceptionContext context) { context.Result = Helpers.GetContentResult(context.Result, "GlobalExceptionFilter.OnException"); }
public void OnException(ExceptionContext context) { _logger.Error(context.Exception,context.Exception.Message); }
public static void AfterOnException( this DiagnosticSource diagnosticSource, ExceptionContext exceptionContext, IExceptionFilter filter) { if (diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.AfterOnException")) { diagnosticSource.Write( "Microsoft.AspNet.Mvc.AfterOnException", new { actionDescriptor = exceptionContext.ActionDescriptor, exceptionContext = exceptionContext, filter = filter }); } }
public virtual void OnException(ExceptionContext context) { }
public override void OnException(ExceptionContext context) { _logger.LogInformation("OnException"); base.OnException(context); }
public virtual Task OnExceptionAsync([NotNull] ExceptionContext context) { OnException(context); return(TaskCache.CompletedTask); }