From a1258c539ec171358c9f6e0c6f689fe725c3f05b Mon Sep 17 00:00:00 2001 From: baizonghao <1719256278@qq.com> Date: 星期四, 23 三月 2023 15:12:33 +0800 Subject: [PATCH] 格式 --- src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java | 21 +++++++-------------- 1 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java index ce97b0b..9e267cc 100644 --- a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java +++ b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java @@ -2,6 +2,7 @@ import com.example.jz.exception.BusinessException; import com.example.jz.modle.R; +import org.springframework.core.annotation.Order; import org.springframework.stereotype.Controller; import org.springframework.validation.BindException; import org.springframework.web.bind.MethodArgumentNotValidException; @@ -15,23 +16,15 @@ @RestControllerAdvice public class DefaultExceptionHandlerConfig { - - @ExceptionHandler(BindException.class) - public R<String> bindExceptionHandler(BindException e) { - e.printStackTrace(); - return R.failed(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); - - } - - @ExceptionHandler(MethodArgumentNotValidException.class) - public R<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { - e.printStackTrace(); - return R.failed(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); - } - @ExceptionHandler(BusinessException.class) public R<String> unauthorizedExceptionHandler(BusinessException e) { e.printStackTrace(); return R.failed(e.getMessage()); } + + @ExceptionHandler(Exception.class) + public R<String> ExceptionHandler(Exception e) { + e.printStackTrace(); + return R.failed(e.getMessage()); + } } -- Gitblit v1.8.0