コード例 #1
0
        /// <summary>
        /// 异常返回值
        /// </summary>
        public virtual object OnException(Exception exception)
        {
            ApiException exp = ResolveException(exception);

            Output output;

            if (exp is IHasValidationErrors errors)
            {
                output = new OutputWithErrors()
                {
                    Code             = 0,
                    Msg              = "操作成功",
                    ErrCode          = exp.Code,
                    ErrMsg           = exp.Message,
                    ValidationErrors = errors.ValidationErrors
                };
            }
            else
            {
                output = new Output()
                {
                    Code    = 0,
                    Msg     = "操作成功",
                    ErrCode = exp.Code,
                    ErrMsg  = exp.Message,
                };
            }
            return(output);
        }
コード例 #2
0
        /// <summary>
        /// 异常返回值
        /// </summary>
        public virtual object OnException(Exception exception)
        {
            ApiException exp = ResolveException(exception);

            Output output = null;

            if (exp is IHasValidationErrors errors)
            {
                output = new OutputWithErrors()
                {
                    Code             = 0,
                    Msg              = "操作失败",
                    ErrCode          = exp.Code,
                    ErrMsg           = exp.Message,
                    ValidationErrors = errors.ValidationErrors
                };
            }
            else
            {
                output = new Output()
                {
                    Code    = 0,
                    Msg     = "操作失败",
                    ErrCode = exp.Code,
                    ErrMsg  = exp.Message,
                };
            }
            if (output != null && _coreOptions.Value != null && _coreOptions.Value.ErrStack)
            {
                if (exp.StackException != null)
                {
                    output.ErrStack = exp.StackException.StackTrace;
                }
                else
                {
                    output.ErrStack = exp.StackTrace;
                }
            }
            return(output);
        }