Add token has expired exception handler
This commit is contained in:
@@ -2,6 +2,7 @@ package top.fatweb.api.handler
|
||||
|
||||
import com.auth0.jwt.exceptions.JWTDecodeException
|
||||
import com.auth0.jwt.exceptions.SignatureVerificationException
|
||||
import com.auth0.jwt.exceptions.TokenExpiredException
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException
|
||||
@@ -32,6 +33,11 @@ class ExceptionHandler {
|
||||
ResponseResult.fail(ResponseCode.SYSTEM_REQUEST_ILLEGAL, e.localizedMessage.split(":")[0], null)
|
||||
}
|
||||
|
||||
is TokenExpiredException -> {
|
||||
log.debug(e.localizedMessage, e)
|
||||
ResponseResult.fail(ResponseCode.SYSTEM_TOKEN_HAS_EXPIRED, e.localizedMessage, null)
|
||||
}
|
||||
|
||||
is MethodArgumentNotValidException -> {
|
||||
log.debug(e.localizedMessage, e)
|
||||
val errorMessage = e.allErrors.map { error -> error.defaultMessage }.joinToString(". ")
|
||||
|
||||
Reference in New Issue
Block a user