From 415a72b7c662dc55bd4f519aede6d8c2e922addd Mon Sep 17 00:00:00 2001 From: lau <1807121535@qq.com> Date: Wed, 10 Jun 2026 17:19:51 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=9C=AA=E7=9F=A5=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=92=8C=E7=B3=BB=E7=BB=9F=E5=BC=82=E5=B8=B8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E7=BC=96=E5=8F=B7=E6=96=B9=E4=BE=BF=E6=9F=A5?= =?UTF-8?q?=E6=89=BE?= 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 f75ffbc24..8bb201172 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; @@ -151,8 +152,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 + "]"); } /** @@ -161,8 +163,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 + "]"); } /**