From 7e72d3ac9c314df5dd7b835fabec6e11a279ae1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Thu, 11 Jun 2026 14:00:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=82=E5=B8=B8=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/handler/GlobalExceptionHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java index 137435eb5..2b314c1c9 100644 --- a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java +++ b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java @@ -1,6 +1,7 @@ package org.dromara.common.web.handler; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; import cn.hutool.http.HttpStatus; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; @@ -149,8 +150,9 @@ public class GlobalExceptionHandler { @ExceptionHandler(RuntimeException.class) public R handleRuntimeException(RuntimeException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - log.error("请求地址'{}',发生未知异常.", requestURI, e); - return R.fail("发生未知异常,请联系管理员"); + String errorId = RandomUtil.randomNumbers(8); + log.error("请求地址'{}',发生未知异常, 错误编号: {}", requestURI, errorId, e); + return R.fail("发生未知异常,请联系管理员 [错误编号: " + errorId + "]"); } /** @@ -159,8 +161,9 @@ public class GlobalExceptionHandler { @ExceptionHandler(Exception.class) public R handleException(Exception e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - log.error("请求地址'{}',发生系统异常.", requestURI, e); - return R.fail("发生系统异常,请联系管理员"); + String errorId = RandomUtil.randomNumbers(8); + log.error("请求地址'{}',发生系统异常, 错误编号: {}", requestURI, errorId, e); + return R.fail("发生系统异常,请联系管理员 [错误编号: " + errorId + "]"); } /**