From da52a1ba7e8fc2d8e633655484e7ff4abed319c8 Mon Sep 17 00:00:00 2001 From: 安瑾然 <107107765@qq.com> Date: 星期二, 12 七月 2022 09:28:42 +0800 Subject: [PATCH] commit --- src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java index c153ac9..f61d378 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.enums.BusinessHttpStatus; import com.example.jz.exception.BusinessException; +import com.example.jz.modle.entity.R; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -19,21 +20,21 @@ @ExceptionHandler(BindException.class) - public ResponseEntity<String> bindExceptionHandler(BindException e) { + public R<String> bindExceptionHandler(BindException e) { e.printStackTrace(); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); + return R.failed(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); } @ExceptionHandler(MethodArgumentNotValidException.class) - public ResponseEntity<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { + public R<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { e.printStackTrace(); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); + return R.failed(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); } @ExceptionHandler(BusinessException.class) - public ResponseEntity<String> unauthorizedExceptionHandler(BusinessException e) { + public R<String> unauthorizedExceptionHandler(BusinessException e) { e.printStackTrace(); - return ResponseEntity.status(e.getHttpStatusCode()).body(e.getMessage()); + return R.failed(e.getMessage()); } } -- Gitblit v1.8.0