Class OpenIdGenerationException

All Implemented Interfaces:
Serializable

public class OpenIdGenerationException extends OpenException
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 Details

    • OpenIdGenerationException

      public OpenIdGenerationException(String message)
      Creates an exception with message 使用消息创建异常
      Parameters:
      message - the error message | 错误消息
    • OpenIdGenerationException

      public OpenIdGenerationException(String message, Throwable cause)
      Creates an exception with message and cause 使用消息和原因创建异常
      Parameters:
      message - the error message | 错误消息
      cause - the cause | 原因
    • OpenIdGenerationException

      public OpenIdGenerationException(String generatorType, String bizTag, String message)
      Creates an exception with generator type, bizTag and message 使用生成器类型、业务标识和消息创建异常
      Parameters:
      generatorType - the generator type | 生成器类型
      bizTag - the business tag | 业务标识
      message - the error message | 错误消息
    • 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

      public String generatorType()
      Gets the generator type 获取生成器类型
      Returns:
      generator type | 生成器类型
    • bizTag

      public String bizTag()
      Gets the business tag 获取业务标识
      Returns:
      business tag | 业务标识
    • clockBackward

      public static OpenIdGenerationException clockBackward(long lastTimestamp, long currentTimestamp)
      Creates a clock backward exception 创建时钟回拨异常
      Parameters:
      lastTimestamp - the last timestamp | 上次时间戳
      currentTimestamp - the current timestamp | 当前时间戳
      Returns:
      exception | 异常
    • invalidParameter

      public static OpenIdGenerationException invalidParameter(String param, long value, String range)
      Creates an invalid parameter exception 创建参数无效异常
      Parameters:
      param - the parameter name | 参数名称
      value - the parameter value | 参数值
      range - the valid range | 有效范围
      Returns:
      exception | 异常
    • segmentExhausted

      public static OpenIdGenerationException segmentExhausted(String bizTag)
      Creates a segment exhausted exception 创建号段耗尽异常
      Parameters:
      bizTag - the business tag | 业务标识
      Returns:
      exception | 异常
    • segmentAllocationFailed

      public static OpenIdGenerationException segmentAllocationFailed(String bizTag, Throwable cause)
      Creates a segment allocation failed exception 创建号段分配失败异常
      Parameters:
      bizTag - the business tag | 业务标识
      cause - the cause | 原因
      Returns:
      exception | 异常
    • invalidIdFormat

      public static OpenIdGenerationException invalidIdFormat(String generatorType, String id)
      Creates an invalid ID format exception 创建ID格式无效异常
      Parameters:
      generatorType - the generator type | 生成器类型
      id - the invalid ID | 无效的ID
      Returns:
      exception | 异常
    • sequenceOverflow

      public static OpenIdGenerationException sequenceOverflow(long maxSequence)
      Creates a sequence overflow exception 创建序列号溢出异常
      Parameters:
      maxSequence - the maximum sequence value | 最大序列号值
      Returns:
      exception | 异常