/// <summary> /// 构造函数 /// </summary> /// <param name="obj">要输出的对象</param> public CustomJsonResult(T obj) { this.JsonRequestBehavior = JsonRequestBehavior.AllowGet; if (obj is CustomException) { var error = obj as CustomException; _errorInfo = new AjaxRequestErrorInfo { errorCode = error.ErrorCode, errorType = error.ExceptionType, message = error.Message }; _iserror = true; } else if (obj is System.Exception) { _errorInfo = new AjaxRequestErrorInfo { message = (obj as Exception).Message }; _iserror = true; } else { _iserror = false; _obj = obj; } }
/// <summary> /// 构造函数 /// </summary> /// <param name="errorMsg">错误消息</param> /// <param name="errorCode">错误码</param> /// <param name="exceptionType">异常类型</param> public CustomJsonResult(string errorMsg, int errorCode, string exceptionType) { this.JsonRequestBehavior = JsonRequestBehavior.AllowGet; _errorInfo = new AjaxRequestErrorInfo { errorCode = errorCode, errorType = exceptionType, message = errorMsg }; _iserror = true; }