Explorar o código

ControllerExceptionHandler 中添加对 RpcException 的处理

reghao hai 3 meses
pai
achega
f2793677c9

+ 4 - 0
common/src/main/java/cn/reghao/tnb/common/exception/ControllerExceptionHandler.java

@@ -4,6 +4,7 @@ import cn.reghao.jutil.jdk.exception.ExceptionUtil;
 import cn.reghao.tnb.common.web.WebResult;
 import cn.reghao.tnb.common.auth.AuthException;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.rpc.RpcException;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
@@ -37,6 +38,9 @@ public class ControllerExceptionHandler {
         String msg;
         if (e instanceof NullPointerException) {
             msg = ExceptionUtil.stackTrace(e);
+        } else if (e instanceof RpcException) {
+            log.error("RPC exception: {}", e.getMessage());
+            msg = e.getMessage();
         } else {
             msg = ExceptionUtil.errorMsg(e);
         }