File tree Expand file tree Collapse file tree
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 Original file line number Diff line number Diff line change 55import java .io .Serializable ;
66
77/**
8- * 微信错误码说明
9- * http://mp.weixin.qq.com/wiki/index.php?title=全局返回码说明
8+ * 微信错误码说明,请阅读: <a href="http://mp.weixin.qq.com/wiki/10/6380dc743053a91c544ffd2b7c959166.html">全局返回码说明</a>
109 * @author Daniel Qian
1110 *
1211 */
@@ -54,4 +53,30 @@ public String toString() {
5453 return "微信错误: errcode=" + errorCode + ", errmsg=" + errorMsg + "\n json:" + json ;
5554 }
5655
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+ }
5782}
Original file line number Diff line number Diff line change @@ -483,9 +483,8 @@ public String qrCodePictureUrl(String ticket) throws WxErrorException {
483483 try {
484484 return String .format (url , URLEncoder .encode (ticket , Charsets .UTF_8 .name ()));
485485 } 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 ();
489488 throw new WxErrorException (error );
490489 }
491490 }
You can’t perform that action at this time.
0 commit comments