From 68985c22a03d280a96e89f4d0e67f144259fab92 Mon Sep 17 00:00:00 2001 From: 安瑾然 <107107765@qq.com> Date: 星期三, 13 七月 2022 11:54:54 +0800 Subject: [PATCH] commit --- 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