Skip to main content

armature_cache/
error.rs

1//! Error types for cache operations.
2
3use thiserror::Error;
4
5/// Result type for cache operations.
6pub type CacheResult<T> = Result<T, CacheError>;
7
8/// Cache-specific errors.
9#[derive(Debug, Error)]
10pub enum CacheError {
11    /// Redis-specific error
12    #[cfg(feature = "redis")]
13    #[error("Redis error: {0}")]
14    Redis(#[from] redis::RedisError),
15
16    /// Memcached-specific error
17    #[cfg(feature = "memcached")]
18    #[error("Memcached error: {0}")]
19    Memcached(#[from] memcache::MemcacheError),
20
21    /// Serialization error
22    #[error("Serialization error: {0}")]
23    Serialization(String),
24
25    /// Deserialization error
26    #[error("Deserialization error: {0}")]
27    Deserialization(String),
28
29    /// Key not found
30    #[error("Key not found: {0}")]
31    NotFound(String),
32
33    /// Connection error
34    #[error("Connection error: {0}")]
35    Connection(String),
36
37    /// Configuration error
38    #[error("Configuration error: {0}")]
39    Config(String),
40
41    /// Invalid URL
42    #[error("Invalid URL: {0}")]
43    InvalidUrl(String),
44
45    /// Operation timeout
46    #[error("Operation timeout")]
47    Timeout,
48
49    /// Generic error
50    #[error("Cache error: {0}")]
51    Other(String),
52}