Prechádzať zdrojové kódy

AuthenticationException

zhou-hao 4 rokov pred
rodič
commit
8069410022

+ 7 - 0
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/CommonErrorControllerAdvice.java

@@ -2,6 +2,7 @@ package org.hswebframework.web.crud.web;
 
 import lombok.extern.slf4j.Slf4j;
 import org.hswebframework.web.authorization.exception.AccessDenyException;
+import org.hswebframework.web.authorization.exception.AuthenticationException;
 import org.hswebframework.web.authorization.exception.UnAuthorizedException;
 import org.hswebframework.web.exception.BusinessException;
 import org.hswebframework.web.exception.NotFoundException;
@@ -150,6 +151,12 @@ public class CommonErrorControllerAdvice {
                 .doOnEach(ReactiveLogger.onNext(r -> log.error(e.getMessage(), e)));
     }
 
+    @ExceptionHandler
+    @ResponseStatus(HttpStatus.BAD_REQUEST)
+    public Mono<ResponseMessage<Object>> handleException(AuthenticationException e) {
+        return Mono.just(ResponseMessage.error(400, e.getCode(), e.getMessage()));
+    }
+
     @ExceptionHandler
     @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
     public Mono<ResponseMessage<Object>> handleException(MediaTypeNotSupportedStatusException e) {