mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 优化微信支付异常处理代码,兼容混乱且变态的微信官方字段命名习惯
This commit is contained in:
@@ -89,7 +89,7 @@ public class WxPayException extends Exception {
|
||||
* @return the wx pay exception
|
||||
*/
|
||||
public static WxPayException from(BaseWxPayResult payBaseResult) {
|
||||
return WxPayException.newBuilder()
|
||||
WxPayException exception = WxPayException.newBuilder()
|
||||
.xmlString(payBaseResult.getXmlString())
|
||||
.returnMsg(payBaseResult.getReturnMsg())
|
||||
.returnCode(payBaseResult.getReturnCode())
|
||||
@@ -97,6 +97,16 @@ public class WxPayException extends Exception {
|
||||
.errCode(payBaseResult.getErrCode())
|
||||
.errCodeDes(payBaseResult.getErrCodeDes())
|
||||
.build();
|
||||
|
||||
if (payBaseResult.getErrorCode() != null) {
|
||||
exception.setErrCode(payBaseResult.getErrorCode());
|
||||
}
|
||||
|
||||
if (payBaseResult.getErrorMessage() != null) {
|
||||
exception.setErrCodeDes(payBaseResult.getErrorMessage());
|
||||
}
|
||||
|
||||
return exception;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user