From d16ea7d4de51b2c6aa509eb776773d43073c3163 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 30 Mar 2021 20:46:17 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=9B=B4=E6=92=AD=E9=97=B4=E5=88=9B=E5=BB=BA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miniapp/api/impl/WxMaLiveServiceImpl.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java index 9e192eb48..20445e4e0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java @@ -18,7 +18,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.*; +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.GET_LIVE_INFO; +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room; /** *
@@ -36,13 +37,20 @@ public class WxMaLiveServiceImpl implements WxMaLiveService {
 
   @Override
   public WxMaCreateRoomResult createRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException {
-    String responseContent = this.wxMaService.post(Room.CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo));
-    JsonObject jsonObject = GsonParser.parse(responseContent);
-    if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
-      throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+    try {
+      String responseContent = this.wxMaService.post(Room.CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo));
+      JsonObject jsonObject = GsonParser.parse(responseContent);
+      if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+        throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+      }
+      return WxMaGsonBuilder.create().fromJson(responseContent, WxMaCreateRoomResult.class);
+    } catch (WxErrorException e) {
+      if (e.getError().getErrorCode() == 300036) {
+        return WxMaGsonBuilder.create().fromJson(e.getError().getJson(), WxMaCreateRoomResult.class);
+      } else {
+        throw e;
+      }
     }
-
-    return WxMaGsonBuilder.create().fromJson(responseContent, WxMaCreateRoomResult.class);
   }
 
   @Override