Преглед изворни кода

global Exception IllegalArgumentException

MOKASZ\lw12420 пре 2 година
родитељ
комит
40f2957f79

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

@@ -51,7 +51,11 @@ public class GlobalExceptionHandler {
         log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
         return RW.fail(HttpStatus.FORBIDDEN.toString(), "没有权限,请联系管理员授权", Mono.just(e.getMessage()));
     }
-
+    @ExceptionHandler(IllegalArgumentException.class)
+    public Mono<RW<Object>> handleIllegalArgumentException(ServerWebExchange exchange, IllegalArgumentException e) {
+        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, MissingRequestValueException e) {