Class OpenIdGenerationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.id.exception.OpenIdGenerationException
- All Implemented Interfaces:
Serializable
ID Generation Exception
ID生成异常
Exception thrown when ID generation fails due to various reasons such as clock backward, segment exhaustion, or invalid parameters.
当ID生成由于各种原因(如时钟回拨、号段耗尽或参数无效)失败时抛出的异常。
Features | 主要功能:
- Generator type tracking - 生成器类型追踪
- Business tag support - 业务标识支持
- Factory methods for common errors - 常见错误的工厂方法
Usage Examples | 使用示例:
try {
long id = generator.generate();
} catch (OpenIdGenerationException e) {
log.error("ID generation failed: type={}, bizTag={}",
e.generatorType(), e.bizTag());
}
Security | 安全性:
- Thread-safe: Yes (immutable exception) - 线程安全: 是(不可变异常)
- Null-safe: No - 空值安全: 否
- Since:
- JDK 25, opencode-base-id V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenIdGenerationException(String message) Creates an exception with message 使用消息创建异常OpenIdGenerationException(String generatorType, String bizTag, String message) Creates an exception with generator type, bizTag and message 使用生成器类型、业务标识和消息创建异常OpenIdGenerationException(String generatorType, String bizTag, String message, Throwable cause) Creates an exception with generator type, bizTag, message and cause 使用生成器类型、业务标识、消息和原因创建异常OpenIdGenerationException(String message, Throwable cause) Creates an exception with message and cause 使用消息和原因创建异常 -
Method Summary
Modifier and TypeMethodDescriptionbizTag()Gets the business tag 获取业务标识static OpenIdGenerationExceptionclockBackward(long lastTimestamp, long currentTimestamp) Creates a clock backward exception 创建时钟回拨异常Gets the generator type 获取生成器类型static OpenIdGenerationExceptioninvalidIdFormat(String generatorType, String id) Creates an invalid ID format exception 创建ID格式无效异常static OpenIdGenerationExceptioninvalidParameter(String param, long value, String range) Creates an invalid parameter exception 创建参数无效异常static OpenIdGenerationExceptionsegmentAllocationFailed(String bizTag, Throwable cause) Creates a segment allocation failed exception 创建号段分配失败异常static OpenIdGenerationExceptionsegmentExhausted(String bizTag) Creates a segment exhausted exception 创建号段耗尽异常static OpenIdGenerationExceptionsequenceOverflow(long maxSequence) Creates a sequence overflow exception 创建序列号溢出异常Methods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenIdGenerationException
Creates an exception with message 使用消息创建异常- Parameters:
message- the error message | 错误消息
-
OpenIdGenerationException
-
OpenIdGenerationException
-
OpenIdGenerationException
public OpenIdGenerationException(String generatorType, String bizTag, String message, Throwable cause) Creates an exception with generator type, bizTag, message and cause 使用生成器类型、业务标识、消息和原因创建异常- Parameters:
generatorType- the generator type | 生成器类型bizTag- the business tag | 业务标识message- the error message | 错误消息cause- the cause | 原因
-
-
Method Details
-
generatorType
-
bizTag
-
clockBackward
Creates a clock backward exception 创建时钟回拨异常- Parameters:
lastTimestamp- the last timestamp | 上次时间戳currentTimestamp- the current timestamp | 当前时间戳- Returns:
- exception | 异常
-
invalidParameter
Creates an invalid parameter exception 创建参数无效异常- Parameters:
param- the parameter name | 参数名称value- the parameter value | 参数值range- the valid range | 有效范围- Returns:
- exception | 异常
-
segmentExhausted
Creates a segment exhausted exception 创建号段耗尽异常- Parameters:
bizTag- the business tag | 业务标识- Returns:
- exception | 异常
-
segmentAllocationFailed
Creates a segment allocation failed exception 创建号段分配失败异常- Parameters:
bizTag- the business tag | 业务标识cause- the cause | 原因- Returns:
- exception | 异常
-
invalidIdFormat
Creates an invalid ID format exception 创建ID格式无效异常- Parameters:
generatorType- the generator type | 生成器类型id- the invalid ID | 无效的ID- Returns:
- exception | 异常
-
sequenceOverflow
Creates a sequence overflow exception 创建序列号溢出异常- Parameters:
maxSequence- the maximum sequence value | 最大序列号值- Returns:
- exception | 异常
-