Class OAuth2Exception
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.oauth2.exception.OAuth2Exception
- All Implemented Interfaces:
Serializable
OAuth2 Exception
OAuth2 异常
Base exception class for all OAuth2 related errors.
所有 OAuth2 相关错误的基础异常类。
Usage Examples | 使用示例:
// Throw with error code
throw new OAuth2Exception(OAuth2ErrorCode.TOKEN_EXPIRED);
// Throw with error code and details
throw new OAuth2Exception(OAuth2ErrorCode.AUTHORIZATION_FAILED, "Invalid code");
// Throw with error code and cause
throw new OAuth2Exception(OAuth2ErrorCode.NETWORK_ERROR, e);
Features | 主要功能:
- OAuth2 protocol exception with error code - 带错误码的OAuth2协议异常
- Carries error description and URI - 携带错误描述和URI
Security | 安全性:
- Thread-safe: Yes (immutable exception) - 线程安全: 是(不可变异常)
- Null-safe: Yes (validates inputs) - 空值安全: 是(验证输入)
- Since:
- JDK 25, opencode-base-oauth2 V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOAuth2Exception(OAuth2ErrorCode errorCode) Create exception with error code 使用错误码创建异常OAuth2Exception(OAuth2ErrorCode errorCode, String details) Create exception with error code and details 使用错误码和详情创建异常OAuth2Exception(OAuth2ErrorCode errorCode, String details, Throwable cause) Create exception with error code, details and cause 使用错误码、详情和原因创建异常OAuth2Exception(OAuth2ErrorCode errorCode, Throwable cause) Create exception with error code and cause 使用错误码和原因创建异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OAuth2ExceptionauthorizationFailed(String details) Create authorization failed exception 创建授权失败异常intcode()Get the error code number 获取错误码数字details()Get additional details 获取附加详情Get the error code 获取错误码static OAuth2ExceptioninvalidConfig(String details) Create invalid config exception 创建无效配置异常static OAuth2ExceptionnetworkError(Throwable cause) Create network error exception 创建网络错误异常static OAuth2ExceptionCreate token expired exception 创建 Token 过期异常static OAuth2ExceptiontokenInvalid(String details) Create token invalid exception 创建 Token 无效异常Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OAuth2Exception
Create exception with error code 使用错误码创建异常- Parameters:
errorCode- the error code | 错误码
-
OAuth2Exception
Create exception with error code and details 使用错误码和详情创建异常- Parameters:
errorCode- the error code | 错误码details- additional details | 附加详情
-
OAuth2Exception
Create exception with error code and cause 使用错误码和原因创建异常- Parameters:
errorCode- the error code | 错误码cause- the cause | 原因
-
OAuth2Exception
Create exception with error code, details and cause 使用错误码、详情和原因创建异常- Parameters:
errorCode- the error code | 错误码details- additional details | 附加详情cause- the cause | 原因
-
-
Method Details
-
errorCode
-
details
-
code
public int code()Get the error code number 获取错误码数字- Returns:
- the error code number | 错误码数字
-
tokenExpired
Create token expired exception 创建 Token 过期异常- Returns:
- the exception | 异常
-
tokenInvalid
Create token invalid exception 创建 Token 无效异常- Parameters:
details- the details | 详情- Returns:
- the exception | 异常
-
authorizationFailed
Create authorization failed exception 创建授权失败异常- Parameters:
details- the details | 详情- Returns:
- the exception | 异常
-
networkError
Create network error exception 创建网络错误异常- Parameters:
cause- the cause | 原因- Returns:
- the exception | 异常
-
invalidConfig
Create invalid config exception 创建无效配置异常- Parameters:
details- the details | 详情- Returns:
- the exception | 异常
-