File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed
weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 5
5
import java .io .Serializable ;
6
6
7
7
/**
8
- * 微信错误码说明
9
- * http://mp.weixin.qq.com/wiki/index.php?title=全局返回码说明
8
+ * 微信错误码说明,请阅读: <a href="http://mp.weixin.qq.com/wiki/10/6380dc743053a91c544ffd2b7c959166.html">全局返回码说明</a>
10
9
* @author Daniel Qian
11
10
*
12
11
*/
@@ -54,4 +53,30 @@ public String toString() {
54
53
return "微信错误: errcode=" + errorCode + ", errmsg=" + errorMsg + "\n json:" + json ;
55
54
}
56
55
56
+ public static Builder newBuilder (){
57
+ return new Builder ();
58
+ }
59
+
60
+ public static class Builder {
61
+ private int errorCode ;
62
+ private String errorMsg ;
63
+
64
+ public Builder setErrorCode (int errorCode ) {
65
+ this .errorCode = errorCode ;
66
+ return this ;
67
+ }
68
+
69
+ public Builder setErrorMsg (String errorMsg ) {
70
+ this .errorMsg = errorMsg ;
71
+ return this ;
72
+ }
73
+
74
+ public WxError build (){
75
+ WxError wxError = new WxError ();
76
+ wxError .setErrorCode (this .errorCode );
77
+ wxError .setErrorMsg (this .errorMsg );
78
+ return wxError ;
79
+ }
80
+
81
+ }
57
82
}
Original file line number Diff line number Diff line change @@ -483,9 +483,8 @@ public String qrCodePictureUrl(String ticket) throws WxErrorException {
483
483
try {
484
484
return String .format (url , URLEncoder .encode (ticket , Charsets .UTF_8 .name ()));
485
485
} catch (UnsupportedEncodingException e ) {
486
- WxError error = new WxError ();
487
- error .setErrorCode (-1 );
488
- error .setErrorMsg (e .getMessage ());
486
+ WxError error = WxError .newBuilder ().setErrorCode (-1 )
487
+ .setErrorMsg (e .getMessage ()).build ();
489
488
throw new WxErrorException (error );
490
489
}
491
490
}
You can’t perform that action at this time.
0 commit comments