Ejemplo n.º 1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="obj">要输出的对象</param>
        public JsonResultEx(object obj)
        {
            this.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            if (obj is YdlCustomException)
            {
                YdlCustomException error = (YdlCustomException)obj;

                _iserror   = true;
                _errorInfo = new AjaxRequestErrorInfo {
                    errorCode = error.ErrorCode, errorType = error.ExceptionType, message = error.Message
                };
            }
            else if (obj is System.Exception)
            {
                _iserror   = true;
                _errorInfo = new AjaxRequestErrorInfo {
                    message = ((System.Exception)obj).Message
                };
            }
            else
            {
                _iserror = false;
                _obj     = obj;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="errorMsg">错误消息</param>
 /// <param name="errorCode">错误码</param>
 /// <param name="exceptionType">异常类型</param>
 public JsonResultEx(string errorMsg, int errorCode, CustomExceptionType exceptionType)
 {
     this.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     _errorInfo = new AjaxRequestErrorInfo {
         errorCode = errorCode, errorType = exceptionType, message = errorMsg
     };
     _iserror = true;
 }