From 822af5cec0f1272e04ba75970f26f5c6fdc999a7 Mon Sep 17 00:00:00 2001 From: xueqingkun Date: Wed, 29 Nov 2023 11:24:16 +0800 Subject: [PATCH] =?UTF-8?q?common=EF=BC=9A=E6=B7=BB=E5=8A=A0=20IllegalArgu?= =?UTF-8?q?mentException=20=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/supervision/config/ResponseConfig.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/virtual-patient-common/src/main/java/com/supervision/config/ResponseConfig.java b/virtual-patient-common/src/main/java/com/supervision/config/ResponseConfig.java index 2eef4f81..de18ce94 100644 --- a/virtual-patient-common/src/main/java/com/supervision/config/ResponseConfig.java +++ b/virtual-patient-common/src/main/java/com/supervision/config/ResponseConfig.java @@ -105,6 +105,17 @@ public class ResponseConfig implements ResponseBodyAdvice { } + /** + * 添加手动校验参数的异常处理 + * @param exception 参数验证异常 + * @return 通用返回值 + */ + @ExceptionHandler(IllegalArgumentException.class) + public GlobalResult manualValidationExceptionResponse(IllegalArgumentException exception) { + log.error(exception.getMessage(), exception); + return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getMessage(), "参数验证异常"); + } + /** * 未知异常处理 *