Class OpenPoolException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenPoolException extends OpenException
OpenPoolException - Pool Exception OpenPoolException - 对象池异常

Exception class for object pool operations, supporting error types and factory methods for common error scenarios.

对象池操作异常类,支持错误类型和常见错误场景的工厂方法。

Features | 主要功能:

  • Error type classification - 错误类型分类
  • Pool name tracking - 池名称追踪
  • Factory methods for common errors - 常见错误的工厂方法
  • Extends OpenException for unified handling - 继承OpenException统一处理

Usage Examples | 使用示例:

throw new OpenPoolException("Pool operation failed");
throw OpenPoolException.exhausted("connection-pool");
throw OpenPoolException.timeout("db-pool", Duration.ofSeconds(5));

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
  • Serializable: Yes - 可序列化: 是
Since:
JDK 25, opencode-base-pool V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenPoolException

      public OpenPoolException(String message)
      Creates exception with message. 创建带消息的异常。
      Parameters:
      message - the message - 异常消息
    • OpenPoolException

      public OpenPoolException(String message, Throwable cause)
      Creates exception with message and cause. 创建带消息和原因的异常。
      Parameters:
      message - the message - 异常消息
      cause - the cause - 原始异常
    • OpenPoolException

      public OpenPoolException(String message, String poolName, OpenPoolException.PoolErrorType errorType)
      Creates exception with full details. 创建带完整详情的异常。
      Parameters:
      message - the message - 异常消息
      poolName - the pool name - 池名称
      errorType - the error type - 错误类型
    • OpenPoolException

      public OpenPoolException(String message, String poolName, OpenPoolException.PoolErrorType errorType, Throwable cause)
      Creates exception with full details and cause. 创建带完整详情和原因的异常。
      Parameters:
      message - the message - 异常消息
      poolName - the pool name - 池名称
      errorType - the error type - 错误类型
      cause - the cause - 原始异常
  • Method Details

    • poolName

      public String poolName()
      Gets the pool name. 获取池名称。
      Returns:
      the pool name - 池名称
    • errorType

      public OpenPoolException.PoolErrorType errorType()
      Gets the error type. 获取错误类型。
      Returns:
      the error type - 错误类型
    • exhausted

      public static OpenPoolException exhausted(String poolName)
      Creates pool exhausted exception. 创建池耗尽异常。
      Parameters:
      poolName - the pool name - 池名称
      Returns:
      the exception - 异常
    • timeout

      public static OpenPoolException timeout(String poolName, Duration timeout)
      Creates timeout exception. 创建超时异常。
      Parameters:
      poolName - the pool name - 池名称
      timeout - the timeout duration - 超时时长
      Returns:
      the exception - 异常
    • validationFailed

      public static OpenPoolException validationFailed(String poolName)
      Creates validation failed exception. 创建验证失败异常。
      Parameters:
      poolName - the pool name - 池名称
      Returns:
      the exception - 异常
    • closed

      public static OpenPoolException closed(String poolName)
      Creates pool closed exception. 创建池已关闭异常。
      Parameters:
      poolName - the pool name - 池名称
      Returns:
      the exception - 异常
    • createFailed

      public static OpenPoolException createFailed(String poolName, Throwable cause)
      Creates object creation failed exception. 创建对象创建失败异常。
      Parameters:
      poolName - the pool name - 池名称
      cause - the cause - 原始异常
      Returns:
      the exception - 异常
    • destroyFailed

      public static OpenPoolException destroyFailed(String poolName, Throwable cause)
      Creates object destruction failed exception. 创建对象销毁失败异常。
      Parameters:
      poolName - the pool name - 池名称
      cause - the cause - 原始异常
      Returns:
      the exception - 异常
    • activateFailed

      public static OpenPoolException activateFailed(String poolName, Throwable cause)
      Creates object activation failed exception. 创建对象激活失败异常。
      Parameters:
      poolName - the pool name - 池名称
      cause - the cause - 原始异常
      Returns:
      the exception - 异常
    • passivateFailed

      public static OpenPoolException passivateFailed(String poolName, Throwable cause)
      Creates object passivation failed exception. 创建对象钝化失败异常。
      Parameters:
      poolName - the pool name - 池名称
      cause - the cause - 原始异常
      Returns:
      the exception - 异常
    • invalidState

      public static OpenPoolException invalidState(String message)
      Creates invalid state exception. 创建非法状态异常。
      Parameters:
      message - the message - 消息
      Returns:
      the exception - 异常