diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxWebResponseExceptionTranslator.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxWebResponseExceptionTranslator.java index c279f338a..857d55cf1 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxWebResponseExceptionTranslator.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxWebResponseExceptionTranslator.java @@ -76,12 +76,6 @@ public class PigxWebResponseExceptionTranslator implements WebResponseExceptionT return handleOAuth2Exception(new MethodNotAllowedException(ase.getMessage(), ase)); } - ase = (OAuth2Exception) throwableAnalyzer.getFirstThrowableOfType(OAuth2Exception.class, causeChain); - - if (ase != null) { - return handleOAuth2Exception((OAuth2Exception) ase); - } - // 处理不合法的令牌错误 401 返回 ase = (InvalidTokenException) throwableAnalyzer.getFirstThrowableOfType(InvalidTokenException.class, causeChain); @@ -89,6 +83,12 @@ public class PigxWebResponseExceptionTranslator implements WebResponseExceptionT return handleOAuth2Exception(new UnauthorizedException(ase.getMessage(), ase)); } + ase = (OAuth2Exception) throwableAnalyzer.getFirstThrowableOfType(OAuth2Exception.class, causeChain); + + if (ase != null) { + return handleOAuth2Exception((OAuth2Exception) ase); + } + return handleOAuth2Exception(new ServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), e)); }