/// <summary> /// 生成错误回应字符串 /// </summary> /// <param name="type">错误类型</param> /// <returns>错误回应字符串</returns> public static string GenError(MornErrorType type) { return(JsonConvert.SerializeObject(new Dictionary <string, object>() { { MornConstants.ERROR_CODE, MornErrorUtil.GetErrorCode(type) }, { MornConstants.ERROR_MESSAGE, MornErrorUtil.GetDescription(type) }, })); }
private T CreateErrorResponse <T>(MornErrorType type, string addition) where T : MornResponse { var rsp = Activator.CreateInstance <T>(); rsp.ErrorCode = MornErrorUtil.GetErrorCode(type); if (string.IsNullOrEmpty(addition)) { rsp.ErrorMessage = MornErrorUtil.GetDescription(type); } else { rsp.ErrorMessage = string.Format("{0} : {1}", MornErrorUtil.GetDescription(type), addition); } return(rsp); }