public WeixinException(Exception innerException, string format, params object[] args)
     : base(string.Format(format, args), innerException)
 {
     ErrorJson         = new WeixinErrorJson();
     ErrorJson.errcode = WeixinResponseStatus.CustomError;
     ErrorJson.errmsg  = string.Format(format, args);
 }
 public WeixinException(string message, Exception innerException)
     : base(message, innerException)
 {
     ErrorJson         = new WeixinErrorJson();
     ErrorJson.errcode = WeixinResponseStatus.CustomError;
     ErrorJson.errmsg  = message;
 }
示例#3
0
        /// <summary>
        /// 获取Post结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="jsonResult"></param>
        /// <returns></returns>
        public static T Deserialize <T>(string jsonResult)
        {
            if (jsonResult.Contains("errcode"))
            {
                //可能发生错误
                WeixinErrorJson errorResult = JsonSerializer.Deserialize <WeixinErrorJson>(jsonResult);
                if (!errorResult.Succeeded)
                {
                    //发生错误
                    throw new WeixinException(
                              string.Format("微信Post请求发生错误!错误码:{0},错误描述:{1}",
                                            errorResult.errcode,
                                            errorResult.errmsg),
                              null, errorResult);
                }
            }

            T result = JsonSerializer.Deserialize <T>(jsonResult);

            return(result);
        }
 public WeixinErrorResultException(string message, Exception inner, WeixinErrorJson errorJson)
     : base(message, inner)
 {
 }
 public WeixinException(Exception innerException, WeixinErrorJson errorJson)
     : base(errorJson.errmsg, innerException)
 {
     ErrorJson = errorJson;
 }
 public WeixinException(WeixinErrorJson errorJson)
     : base(errorJson.errmsg)
 {
     ErrorJson = errorJson;
 }