From 2976e1e20ef35775630a11f9fc7563ab5b6216f0 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 30 十月 2026 19:12:29 +0800
Subject: [PATCH] fix(api): 修复全量接口测试发现的 500 系统异常

---
 yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
index 0eb7f5e..d8f1054 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
@@ -115,6 +115,10 @@
         if (ex instanceof AccessDeniedException) {
             return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
         }
+        // 鍙傛暟鏍¢獙绫诲紓甯革紙濡� Assert.notNull 鎶涘嚭鐨� IllegalArgumentException锛夊睘浜庡鎴风闂锛屼笉搴旀寜 500 澶勭悊
+        if (ex instanceof IllegalArgumentException) {
+            return illegalArgumentExceptionHandler((IllegalArgumentException) ex);
+        }
         return defaultExceptionHandler(request, ex);
     }
 
@@ -268,6 +272,18 @@
     }
 
     /**
+     * 澶勭悊鍙傛暟闈炴硶寮傚父
+     *
+     * 鏉ユ簮鏄紝涓氬姟浠g爜涓娇鐢� {@link Assert#notNull} 绛夋柇瑷�鏍¢獙鍏ュ弬锛屾垨缂撳瓨娉ㄨВ浣跨敤绌� key銆�
+     * 杩欑被闂灞炰簬璋冪敤鏂逛紶鍙備笉姝g‘锛岃繑鍥� 400 鑰屼笉鏄� 500锛岄伩鍏嶅墠绔妸鍙傛暟闂璇垽涓虹郴缁熸晠闅溿��
+     */
+    @ExceptionHandler(value = IllegalArgumentException.class)
+    public CommonResult<?> illegalArgumentExceptionHandler(IllegalArgumentException ex) {
+        log.warn("[illegalArgumentExceptionHandler]", ex);
+        return CommonResult.error(BAD_REQUEST.getCode(), ex.getMessage());
+    }
+
+    /**
      * 澶勭悊 Spring Security 鏉冮檺涓嶈冻鐨勫紓甯�
      *
      * 鏉ユ簮鏄紝浣跨敤 @PreAuthorize 娉ㄨВ锛孉OP 杩涜鏉冮檺鎷︽埅

--
Gitblit v1.9.3