Example #1
0
        public void OnException(ExceptionContext context)
        {
            // 写入日志
            UseLog.Error(context.Exception.Message, context.Exception);

            //处理各种异常
            context.ExceptionHandled = true;
            context.Result           = new CustomExceptionResult(context.Exception);
        }
        public ValidationFailedResultModel(ModelStateDictionary modelState)
        {
            Code        = 422;
            Message     = "参数不合法";
            InnerMassge = modelState.Keys
                          .SelectMany(key => modelState[key].Errors
                                      .Select(x => new ValidationError(key, x.ErrorMessage)))
                          .ToList();

            UseLog.Error(InnerMassge.ToJson());
        }