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(), "参数验证异常"); + } + /** * 未知异常处理 *