From 69b7b1ddb3ba056b8ed458bdd44cf36e4080b5bd Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期四, 04 七月 2024 17:57:59 +0800
Subject: [PATCH] mq配置修改2

---
 src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java b/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java
index cc0c2c8..4f1977a 100644
--- a/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java
+++ b/src/main/java/com/ycl/jxkg/config/spring/exception/ExceptionHandle.java
@@ -15,6 +15,7 @@
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
@@ -26,11 +27,13 @@
  * Copyright (C), 2020-2024, 姝︽眽鎬濈淮璺宠穬绉戞妧鏈夐檺鍏徃
  * @date 2021/12/25 9:45
  */
-@ControllerAdvice
+@RestControllerAdvice
 public class ExceptionHandle {
 
     private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
-    /** 鍏徃椤圭洰鐨勫寘缁撴瀯锛岀敤浜庣缉鐭敊璇棩蹇楃殑闀垮害 */
+    /**
+     * 鍏徃椤圭洰鐨勫寘缁撴瀯锛岀敤浜庣缉鐭敊璇棩蹇楃殑闀垮害
+     */
     private final static String COMPANY_PACKAGE = "com.ycl.jxkg.";
 
     /**
@@ -45,6 +48,20 @@
         String errMsg = String.format("绯荤粺寮傚父-%s", e.getMessage());
         this.printExceptionLocation(e, request, errMsg);
         return new Result<>(SystemCode.InnerError.getCode(), SystemCode.InnerError.getMessage());
+    }
+
+    /**
+     * Handler rest response.
+     *
+     * @param e the e
+     * @return the rest response
+     */
+    @ExceptionHandler(RuntimeException.class)
+    @ResponseBody
+    public Result handler(RuntimeException e, HttpServletRequest request) {
+        String errMsg = String.format("绯荤粺寮傚父-%s", e.getMessage());
+        this.printExceptionLocation(e, request, errMsg);
+        return new Result<>(SystemCode.InnerError.getCode(), e.getMessage());
     }
 
     /**
@@ -98,6 +115,7 @@
 
     /**
      * 鎵撳嵃寮傚父鍑虹幇浣嶇疆
+     *
      * @param e
      */
     private void printExceptionLocation(Throwable e, HttpServletRequest request, String errMsg) {

--
Gitblit v1.8.0