Class CacheException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.github.dhruv1110.jcachex.exceptions.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CacheException.ErrorType
Error classification for handling different types of cache errors.
-
Constructor Summary
Constructors Constructor Description CacheException(String message)
Constructs a new cache exception with the specified detail message.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.CacheException(String message, Throwable cause)
Constructs a new cache exception with the specified detail message and cause.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getErrorCode()
Returns the specific error code, if available.CacheException.ErrorType
getErrorType()
Returns the error type classification.boolean
isRetryable()
Returns whether this operation can be retried.String
toString()
Returns a comprehensive string representation of this exception.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
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 messagecause
- 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 messageerrorType
- the type of errorerrorCode
- the specific error coderetryable
- 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 messagecause
- the causeerrorType
- the type of errorerrorCode
- the specific error coderetryable
- 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
-
-