Class OpenCacheException

All Implemented Interfaces:
OpenExceptionMeta, Serializable
Direct Known Subclasses:
TimeoutCache.CacheTimeoutException

public class OpenCacheException extends OpenException
Open Cache Exception - Unified exception for cache operations OpenCache 异常 - 缓存操作的统一异常

Extends OpenException to maintain consistent exception hierarchy.

继承 OpenException 以保持一致的异常体系。

Features | 主要功能:

  • Cache name tracking - 缓存名称跟踪
  • Key information - 键信息
  • Cause chaining - 原因链

Usage Examples | 使用示例:

// Create exception - 创建异常
throw new OpenCacheException("users", "user:1001", "Failed to load user");

// With cause - 带原因
throw new OpenCacheException("users", "user:1001", cause);

Security | 安全性:

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

    • OpenCacheException

      public OpenCacheException(String message)
      Create exception with message 使用消息创建异常
      Parameters:
      message - the message | 消息
    • OpenCacheException

      public OpenCacheException(String message, Throwable cause)
      Create exception with message and cause 使用消息和原因创建异常
      Parameters:
      message - the message | 消息
      cause - the cause | 原因
    • OpenCacheException

      public OpenCacheException(String cacheName, Object key, String message)
      Create exception with cache name, key and message 使用缓存名称、键和消息创建异常
      Parameters:
      cacheName - the cache name | 缓存名称
      key - the key | 键
      message - the message | 消息
    • OpenCacheException

      public OpenCacheException(String cacheName, Object key, Throwable cause)
      Create exception with cache name, key and cause 使用缓存名称、键和原因创建异常
      Parameters:
      cacheName - the cache name | 缓存名称
      key - the key | 键
      cause - the cause | 原因
    • OpenCacheException

      public OpenCacheException(String cacheName, Object key, String message, Throwable cause)
      Create exception with cache name, key, message and cause 使用缓存名称、键、消息和原因创建异常
      Parameters:
      cacheName - the cache name | 缓存名称
      key - the key | 键
      message - the message | 消息
      cause - the cause | 原因
  • Method Details

    • getCacheName

      public Optional<String> getCacheName()
      Get cache name 获取缓存名称
      Returns:
      optional containing cache name | 包含缓存名称的 Optional
    • getKey

      public Optional<Object> getKey()
      Get key 获取键
      Returns:
      optional containing key | 包含键的 Optional
    • loadingFailed

      public static OpenCacheException loadingFailed(String cacheName, Object key, Throwable cause)
      Create loading exception 创建加载异常
      Parameters:
      cacheName - cache name | 缓存名称
      key - the key | 键
      cause - the cause | 原因
      Returns:
      exception | 异常
    • timeout

      public static OpenCacheException timeout(String cacheName, Object key)
      Create timeout exception 创建超时异常
      Parameters:
      cacheName - cache name | 缓存名称
      key - the key | 键
      Returns:
      exception | 异常
    • capacityExceeded

      public static OpenCacheException capacityExceeded(String cacheName, long maxCapacity)
      Create capacity exceeded exception 创建容量超出异常
      Parameters:
      cacheName - cache name | 缓存名称
      maxCapacity - maximum capacity | 最大容量
      Returns:
      exception | 异常