Exemplo n.º 1
0
        public virtual void OnException(ExceptionContext filterContext)
        {
            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                //Because its a exception raised after ajax invocation
                //Lets return Json

                LogRecordService.Error(filterContext.Exception);
                //filterContext.Result = new JsonResult
                //{
                //    Data = new { result = false, errmsg = filterContext.Exception.Message },
                //    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                //};

                filterContext.ExceptionHandled = true;
                filterContext.HttpContext.Response.StatusCode = 500;
            }
        }
Exemplo n.º 2
0
        protected void LogException(Exception exc)
        {
            if (exc == null)
            {
                return;
            }

            //ignore 404 HTTP errors
            var httpException = exc as HttpException;

            if (httpException != null && httpException.GetHttpCode() == 404)
            {
                return;
            }

            try
            {
                LogRecordService.Error(exc);
            }
            catch (Exception)
            {
                //don't throw new exception if occurs
            }
        }