ソースを参照

:whale: 重写业务框架 ActionMethodExceptionProcess,触发验证时,打印异常栈信息

渔民小镇 1 年間 前
コミット
a7cabe5d18

+ 46 - 0
common/common-core/src/main/java/com/iohao/mmo/common/core/flow/internal/DebugActionMethodExceptionProcess.java

@@ -0,0 +1,46 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.common.core.flow.internal;
+
+import com.iohao.game.action.skeleton.core.exception.ActionErrorEnum;
+import com.iohao.game.action.skeleton.core.exception.MsgException;
+import com.iohao.game.action.skeleton.core.flow.ActionMethodExceptionProcess;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 增加触发验证时,打印异常栈信息
+ *
+ * @author 渔民小镇
+ * @date 2023-08-09
+ */
+@Slf4j
+public class DebugActionMethodExceptionProcess implements ActionMethodExceptionProcess {
+    @Override
+    public MsgException processException(final Throwable e) {
+
+        if (e instanceof MsgException msgException) {
+            log.error(e.getMessage(), e);
+            return msgException;
+        }
+
+        // 到这里,一般不是用户自定义的错误,很可能是开发者引入的第三方包或自身未捕获的错误等情况
+        log.error(e.getMessage(), e);
+        return new MsgException(ActionErrorEnum.systemOtherErrCode);
+    }
+}

+ 5 - 0
common/common-core/src/main/java/com/iohao/mmo/common/logic/server/LogicServerKit.java

@@ -27,6 +27,7 @@ import com.iohao.game.bolt.broker.core.common.processor.hook.ClientProcessorHook
 import com.iohao.mmo.common.config.GameCode;
 import com.iohao.mmo.common.core.flow.MyFlowContext;
 import com.iohao.mmo.common.core.flow.internal.DebugActionAfter;
+import com.iohao.mmo.common.core.flow.internal.DebugActionMethodExceptionProcess;
 import com.iohao.mmo.common.processor.hook.MyRequestMessageClientProcessorHook;
 import lombok.experimental.UtilityClass;
 
@@ -45,8 +46,12 @@ public class LogicServerKit {
                 .addErrorCode(GameCode.values());
 
         BarSkeletonBuilder builder = LogicServerCreateKit.createBuilder(config);
+
         // 重写业务框架 ActionAfter
         builder.setActionAfter(new DebugActionAfter());
+        // 重写业务框架 ActionMethodExceptionProcess
+        builder.setActionMethodExceptionProcess(new DebugActionMethodExceptionProcess());
+
         // 使用自定义 FlowContext
         builder.setFlowContextFactory(MyFlowContext::new);
 

+ 1 - 0
logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/internal/equip/BuildEquipUseProcess.java

@@ -83,6 +83,7 @@ public class BuildEquipUseProcess implements UseProcess {
     }
 
     private BagItem createEquip(BuildEquipParse.BuildParam buildParam) {
+        // TODO 这里后续调用【装备模块】生成装备的 action,目前先暂时写假数据。
         // 得到对应装备的 itemId
         String equipItemId = buildParam.getEquipItemId();