public override void OnException(ExceptionContext filterContext) { string controllerName = (string)filterContext.RouteData.Values["controller"]; string actionName = (string)filterContext.RouteData.Values["action"]; ExceptionAttribute exceptionAttr = (ExceptionAttribute)Attribute.GetCustomAttribute(filterContext.Exception.GetType(), typeof(ExceptionAttribute)); if (exceptionAttr._operationType == "RollBackAndSendEmail") { //TBD } if (exceptionAttr._operationType == "SendEmailAndLogInSystem") { //Do log and send email. } filterContext.Result = new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { error = true, message = filterContext.Exception.Message, } }; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = 500; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; }
internal QueryTalkException( object exceptionCreator, QueryTalkExceptionType exceptionType, string arguments, string method = null) { _hasReport = true; _exceptionType = exceptionType; _exceptionAttribute = exceptionType.GetAttributeOfType <ExceptionAttribute>(); _arguments = arguments ?? Text.NotAvailable; _tip = _exceptionAttribute.Tip; _method = method; }
public void Setup() { ExceptionFilter = new ExceptionAttribute(); }