Skip to content

Commit b19dc7b

Browse files
committed
Improve error message of the failure of getting prepayid.
1 parent 379aae9 commit b19dc7b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,8 @@ public WxMpPrepayIdResult getPrepayId(final Map<String, String> parameters) {
835835
WxMpPrepayIdResult wxMpPrepayIdResult = (WxMpPrepayIdResult) xstream.fromXML(responseContent);
836836
return wxMpPrepayIdResult;
837837
} catch (IOException e) {
838-
e.printStackTrace();
838+
throw new RuntimeException("Failed to get prepay id due to IO exception.", e);
839839
}
840-
return new WxMpPrepayIdResult();
841840
}
842841

843842
final String[] REQUIRED_ORDER_PARAMETERS = new String[] { "appid", "mch_id", "body", "out_trade_no", "total_fee", "spbill_create_ip", "notify_url",
@@ -875,7 +874,7 @@ public Map<String, String> getJSSDKPayInfo(Map<String, String> parameters) {
875874
WxMpPrepayIdResult wxMpPrepayIdResult = getPrepayId(parameters);
876875
String prepayId = wxMpPrepayIdResult.getPrepay_id();
877876
if (prepayId == null || prepayId.equals("")) {
878-
throw new RuntimeException("get prepayid error");
877+
throw new RuntimeException(String.format("Failed to get prepay id due to error code '%s'(%s).", wxMpPrepayIdResult.getErr_code(), wxMpPrepayIdResult.getErr_code_des()));
879878
}
880879

881880
Map<String, String> payInfo = new HashMap<String, String>();

0 commit comments

Comments
 (0)