private void HandleAjaxError(ExceptionContext context) { context.Result = new AbpJsonResult { Data = new AbpMvcAjaxResponse(AbpErrorInfo.ForException(context.Exception)) }; }
public override void OnException(HttpActionExecutedContext context) { LogHelper.Logger.Error(context.Exception.Message, context.Exception); context.Response = context.Request.CreateResponse( HttpStatusCode.OK, new AbpAjaxResponse(AbpErrorInfo.ForException(context.Exception)) ); }
private void HandleNonAjaxError(ExceptionContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (context.ExceptionHandled || context.IsChildAction) { return; } // If custom errors are disabled, we need to let the normal ASP.NET exception handler // execute so that the user can see useful debugging information. if (!context.HttpContext.IsCustomErrorEnabled) //TODO: To check or not to check this? { return; } //TODO: Move this to another class to be able to share! var message = context.Exception is UserFriendlyException ? context.Exception.Message : "General exception message here!"; context.Result = new ViewResult { ViewName = View, MasterName = Master, ViewData = new ViewDataDictionary <AbpErrorInfo>(AbpErrorInfo.ForException(context.Exception)), TempData = context.Controller.TempData }; context.ExceptionHandled = true; context.HttpContext.Response.Clear(); context.HttpContext.Response.StatusCode = 500; // Certain versions of IIS will sometimes use their own error page when // they detect a server error. Setting this property indicates that we // want it to try to render ASP.NET MVC's error page instead. context.HttpContext.Response.TrySkipIisCustomErrors = true; }