wangcheng 2 лет назад
Родитель
Сommit
6cb25d4bbc

+ 5 - 5
launch-admin/src/main/java/com/webflux/launchadmin/global/GlobalExceptionHandler.java

@@ -30,10 +30,8 @@ import java.util.Objects;
 @RestControllerAdvice
 @Slf4j
 public class GlobalExceptionHandler {
-    @ResponseBody
-    @ResponseStatus(HttpStatus.BAD_REQUEST)
     @ExceptionHandler(BaseException.class)
-    public Mono<RW<Object>> handleException(BaseException e, ServerWebExchange exchange) {
+    public Mono<RW<Object>> handleException(ServerWebExchange exchange, BaseException e) {
         log.warn("接口异常 uri={} e={}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
         return RW.fail("500", e.getMessage(), Mono.just(e.getMessage()));
     }
@@ -51,12 +49,14 @@ public class GlobalExceptionHandler {
         log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
         return RW.fail(HttpStatus.FORBIDDEN.toString(), "没有权限,请联系管理员授权", Mono.just(e.getMessage()));
     }
+
     //@ResponseStatus(HttpStatus.BAD_REQUEST)
     @ExceptionHandler(MissingRequestValueException.class)
-    public Mono<RW<Object>> handleMissingRequestValueException(ServerWebExchange exchange, AccessDeniedException e) {
+    public Mono<RW<Object>> handleMissingRequestValueException(ServerWebExchange exchange, MissingRequestValueException e) {
         log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
         return RW.fail(HttpStatus.FORBIDDEN.toString(), "请求参数异常", Mono.just(e.getMessage()));
     }
+
     @ExceptionHandler(AccountExpiredException.class)
     public Mono<RW<Object>> handleAccountExpiredException(ServerWebExchange exchange, AccountExpiredException e) {
         log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
@@ -64,7 +64,7 @@ public class GlobalExceptionHandler {
     }
 
     @ExceptionHandler(DataAccessException.class)
-    public Mono<RW<Object>> handleDataAccessException(ServerWebExchange exchange, AccountExpiredException e) {
+    public Mono<RW<Object>> handleDataAccessException(ServerWebExchange exchange, DataAccessException e) {
         log.error("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
         return RW.fail(e.getMessage(), Mono.just(e.getMessage()));
     }