@ ControllerAdvice+@ExceptionHandler did not handle the exception or failed to catch the exception

1.@ControllerAdvice+@ExceptionHandler does not handle exceptions, or cannot catch exceptions

2. When shiro integration jwt is being done, the following exception is thrown when jwt token expires or is illegal. The code is as follows: public static void verify (String token, String userId, String secret) {

    try {
        Algorithm algorithm = Algorithm.HMAC256(secret);
        JWTVerifier verifier = JWT.require(algorithm).withClaim(userPrimaryKey, userId).build();
        verifier.verify(token);
    } catch (TokenExpiredException exception) {
        log.info("token ,:{}", token);
        throw new ExpiredCredentialsException(EnumErrorCode.apiAuthorizationExpired.getMsg());
    }catch (InvalidClaimException exception2){
        log.info("token ,:{}", token);
        throw new AuthenticationException(EnumErrorCode.apiAuthorizationInvalid.getMsg());
    }catch (Exception exception3){
        log.info("token :{}", token);
        throw new IFastApiException(EnumErrorCode.apiAuthorizationInvalid.getCodeStr());
    }
}

@RestControllerAdvice()
@ExceptionHandler(ShiroException.class)
public Result<String> handleAuthorizationException(ShiroException e) {
    log.error(e.getMessage());
    if(e instanceof IncorrectCredentialsException) {
        return Result.build(EnumErrorCode.apiAuthorizationFailed.getCode(), EnumErrorCode.apiAuthorizationFailed.getMsg());
    }else if(e instanceof ExpiredCredentialsException) {
        return Result.build(EnumErrorCode.apiAuthorizationExpired.getCode(), EnumErrorCode.apiAuthorizationExpired.getMsg());
    }
    return Result.build(EnumErrorCode.notAuthorization.getCode(), EnumErrorCode.notAuthorization.getMsg());
}

3. According to theory, when token expires, an ExpiredCredentialsException exception will be thrown. This exception is a subclass of shiroException and should be accepted, but it will only be thrown if it is not received alive or dead. There is no further processing. Preliminary doubt whether other uncaught exceptions have been thrown

.
Jul.17,2022

I have encountered the same problem as you. I wonder if it has been solved. When my front end uses get to submit, the exception in the interceptor is successfully handled, but it is not possible to change it to post? Do not know how to solve


has the landlord solved it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ed483c-492b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ed483c-492b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?