PMSHandleErrorAttribute.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using QWPlatform.SystemLibrary.LogManager;
  7. namespace PMS.WebUI
  8. {
  9. /// <summary>
  10. /// 创 建 人:王海洋
  11. /// 创建日期:2018-12-10
  12. /// 功能描述:异常处理
  13. /// </summary>
  14. public class PMSHandleErrorAttribute : HandleErrorAttribute, IExceptionFilter
  15. {
  16. public override void OnException(ExceptionContext filterContext)
  17. {
  18. Exception exception = filterContext.Exception;
  19. string controllerName = (string)filterContext.RouteData.Values["controller"];
  20. string actionName = (string)filterContext.RouteData.Values["action"];
  21. //HandleErrorInfo model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName);
  22. //ExceptionContext exceptionContext = filterContext;
  23. //记录日志
  24. Logger.Instance.Error(string.Format("访问控制器:{0},方法:{1},出现错误", controllerName, actionName), exception);
  25. base.OnException(filterContext);
  26. }
  27. }
  28. }