From 4274f2ede6ff8a929fe4cc7cc51aa8fa4e1eca19 Mon Sep 17 00:00:00 2001 From: danaodai Date: Mon, 12 May 2025 07:37:57 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E5=B1=80=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=99=A8=E6=B7=BB=E5=8A=A0=20BaseException?= =?UTF-8?q?=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/exception/GlobalExceptionHandler.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/continew-common/src/main/java/top/continew/admin/common/config/exception/GlobalExceptionHandler.java b/continew-common/src/main/java/top/continew/admin/common/config/exception/GlobalExceptionHandler.java index 1222e15b..b7862c6f 100644 --- a/continew-common/src/main/java/top/continew/admin/common/config/exception/GlobalExceptionHandler.java +++ b/continew-common/src/main/java/top/continew/admin/common/config/exception/GlobalExceptionHandler.java @@ -32,6 +32,7 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep import org.springframework.web.multipart.MultipartException; import org.springframework.web.servlet.NoHandlerFoundException; import top.continew.starter.core.exception.BadRequestException; +import top.continew.starter.core.exception.BaseException; import top.continew.starter.core.exception.BusinessException; import top.continew.starter.web.model.R; @@ -47,6 +48,16 @@ import top.continew.starter.web.model.R; @RestControllerAdvice public class GlobalExceptionHandler { + + /** + * 自定义基类异常 + */ + @ExceptionHandler(BaseException.class) + public R handleBaseException(BaseException e, HttpServletRequest request) { + log.error("[{}] {}", request.getMethod(), request.getRequestURI(), e); + return R.fail(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), e.getMessage()); + } + /** * 业务异常 */