Class CacheException

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    CacheConfigurationException, CacheOperationException

    public class CacheException
    extends RuntimeException
    Base exception class for all JCacheX-related exceptions.

    This is the root exception class for all cache-related errors in JCacheX. It provides a common base for all cache exceptions and includes utilities for error classification and handling.

    Exception Hierarchy:

     CacheException
     ├── CacheConfigurationException
     ├── CacheOperationException
     │   ├── CacheWriteException
     │   ├── CacheReadException
     │   └── CacheEvictionException
     ├── CacheLoadingException
     ├── CacheCapacityException
     └── CacheTimeoutException
     

    Usage Examples:

    
     try {
         cache.put(key, value);
     } catch (CacheException e) {
         // Handle all cache-related exceptions
         logger.error("Cache operation failed: " + e.getMessage(), e);
         // Implement fallback logic
     }
     
    Since:
    1.0.0
    See Also:
    Serialized Form
    • Constructor Detail

      • CacheException

        public CacheException​(String message)
        Constructs a new cache exception with the specified detail message.
        Parameters:
        message - the detail message
      • CacheException

        public CacheException​(String message,
                              Throwable cause)
        Constructs a new cache exception with the specified detail message and cause.
        Parameters:
        message - the detail message
        cause - the cause
      • CacheException

        public CacheException​(String message,
                              CacheException.ErrorType errorType,
                              String errorCode,
                              boolean retryable)
        Constructs a new cache exception with the specified detail message, error type, and error code.
        Parameters:
        message - the detail message
        errorType - the type of error
        errorCode - the specific error code
        retryable - whether this operation can be retried
      • CacheException

        public CacheException​(String message,
                              Throwable cause,
                              CacheException.ErrorType errorType,
                              String errorCode,
                              boolean retryable)
        Constructs a new cache exception with the specified detail message, cause, error type, and error code.
        Parameters:
        message - the detail message
        cause - the cause
        errorType - the type of error
        errorCode - the specific error code
        retryable - whether this operation can be retried
    • Method Detail

      • getErrorType

        public CacheException.ErrorType getErrorType()
        Returns the error type classification.
        Returns:
        the error type
      • getErrorCode

        public String getErrorCode()
        Returns the specific error code, if available.
        Returns:
        the error code, or null if not specified
      • isRetryable

        public boolean isRetryable()
        Returns whether this operation can be retried.
        Returns:
        true if the operation can be retried, false otherwise
      • toString

        public String toString()
        Returns a comprehensive string representation of this exception.
        Overrides:
        toString in class Throwable
        Returns:
        a string representation including error type and code