redis_sentinel_pool/
error.rs1use thiserror::Error;
7
8#[derive(Debug, Error)]
10pub enum SentinelPoolError {
11 #[error("redis error: {0}")]
13 Redis(#[from] redis::RedisError),
14
15 #[error("connection pool error: {0}")]
17 Pool(String),
18
19 #[error("invalid configuration: {0}")]
21 Config(String),
22
23 #[error("operation failed after {attempts} attempts: {source}")]
25 RetryExhausted {
26 attempts: u32,
28 #[source]
30 source: redis::RedisError,
31 },
32
33 #[error("sentinel watcher stopped: {0}")]
35 WatcherStopped(String),
36}
37
38pub type Result<T> = std::result::Result<T, SentinelPoolError>;
40
41impl<E> From<bb8::RunError<E>> for SentinelPoolError
42where
43 E: Into<SentinelPoolError> + std::fmt::Display,
44{
45 fn from(value: bb8::RunError<E>) -> Self {
46 match value {
47 bb8::RunError::User(e) => e.into(),
48 bb8::RunError::TimedOut => SentinelPoolError::Pool("timed out waiting for connection".into()),
49 }
50 }
51}