pub enum RedisError {
Show 17 variants
Connection {
addr: Option<String>,
source: Error,
},
Protocol(ProtocolError),
Redis(String),
UnexpectedResponse {
expected: &'static str,
actual: String,
},
ConnectionClosed,
InvalidUrl(String),
TransactionAborted,
ConnectionInUse,
TypeMismatch {
expected: &'static str,
},
IndexOutOfBounds {
index: usize,
len: usize,
},
ReconnectFailed {
attempts: usize,
last_error: Arc<RedisError>,
},
CircuitOpen,
PoolAcquisitionTimeout {
waited: Duration,
pool_size: usize,
},
QueueFull,
ConnectTimeout,
CommandTimeout,
Json(Error),
}Expand description
Errors returned by redis-tower operations.
Covers the full error surface: transport I/O, protocol framing, Redis
server errors, type conversion mismatches, and reconnection failures.
Use is_retryable and
is_connection_error to classify
errors for retry and reconnection logic.
Variants§
Connection
Connection-level I/O error.
When the error originates at a connect site, addr carries the address
the connection attempt failed against (host:port, or a unix socket
path), which is invaluable for diagnostics when a client manages
several endpoints (pool, cluster, sentinel). For I/O errors that arise
after a connection is established – or where no single address applies
– addr is None.
The blanket From<std::io::Error> conversion used by ? produces
addr: None; use RedisError::connection to attach an address, and
read it back with RedisError::connection_addr.
Fields
Protocol(ProtocolError)
RESP protocol error (parsing or serialization).
Redis(String)
Redis server returned an error response.
UnexpectedResponse
Response frame did not match the expected type.
Fields
ConnectionClosed
Connection is closed.
InvalidUrl(String)
URL parsing error.
TransactionAborted
Transaction was aborted due to a WATCH violation.
ConnectionInUse
Failed to extract the connection because it has other references.
TypeMismatch
Type mismatch when extracting a pipeline/transaction result.
IndexOutOfBounds
Index out of bounds when accessing a pipeline or transaction result.
ReconnectFailed
Reconnection failed after exhausting all retries.
Fields
last_error: Arc<RedisError>The shared structured cause from the final reconnect attempt.
This is reference-counted so every waiter released by the same failed reconnect campaign observes the identical error variant and metadata without reducing it to display text.
CircuitOpen
The circuit breaker is open; request rejected without touching the service.
PoolAcquisitionTimeout
Timed out waiting to acquire a connection from the pool.
Fields
QueueFull
A bounded command queue is full; the caller should shed load.
This can be returned by the auto-pipeline channel or an explicitly configured resilient-client offline queue.
ConnectTimeout
TCP connection attempt timed out before the OS completed the handshake.
Returned by crate::RedisConnection::connect_with_timeout and by
ResilientConnection when a
connect_timeout is configured on ReconnectConfig.
CommandTimeout
A command exceeded its configured duration or absolute deadline.
Returned when a command exceeds a configured timeout or an absolute
deadline carried by WithDeadline.
Json(Error)
serde only.JSON serialization or deserialization error (serde_json).
Only present when the serde feature is enabled. Allows callers to
distinguish serialization failures from network or server errors by
matching on RedisError::Json(_).
Implementations§
Source§impl RedisError
impl RedisError
Sourcepub fn connection(addr: impl Into<String>, source: Error) -> RedisError
pub fn connection(addr: impl Into<String>, source: Error) -> RedisError
Build a RedisError::Connection that records the address the
connection attempt failed against.
Connect sites use this instead of the blanket ? conversion so that
the resulting error carries the address (host:port or unix socket
path) for diagnostics.
use redis_tower_core::RedisError;
use std::io::{Error, ErrorKind};
let err = RedisError::connection(
"127.0.0.1:6379",
Error::new(ErrorKind::ConnectionRefused, "refused"),
);
assert_eq!(err.connection_addr(), Some("127.0.0.1:6379"));
assert!(err.to_string().contains("127.0.0.1:6379"));Sourcepub fn connection_addr(&self) -> Option<&str>
pub fn connection_addr(&self) -> Option<&str>
Returns the address a connection error failed against, if it was recorded.
Returns None for non-connection errors and for connection errors that
did not capture an address (for example I/O errors converted via the
blanket ? conversion).
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is transient and the operation is worth retrying.
Connection and protocol errors are retryable. Redis command errors (WRONGTYPE, NOSCRIPT, etc.) are not – they will fail the same way on retry.
Note: TransactionAborted is retryable at the transaction level
(rebuild and re-execute) but not at the command level.
§Safety Warning
For connection errors (RedisError::Connection and
RedisError::ConnectionClosed), the command may have been received
and executed by Redis before the connection dropped. Retrying a
non-idempotent write (INCR, LPUSH, ZADD, etc.) can silently duplicate
data. Always check Command::idempotent before retrying on a
connection error.
Sourcepub fn is_wrongtype(&self) -> bool
pub fn is_wrongtype(&self) -> bool
Returns true if this is a WRONGTYPE error.
Sourcepub fn is_noscript(&self) -> bool
pub fn is_noscript(&self) -> bool
Returns true if this is a NOSCRIPT error.
Sourcepub fn is_tryagain(&self) -> bool
pub fn is_tryagain(&self) -> bool
Returns true if this is a TRYAGAIN error (cluster).
Redis returns TRYAGAIN for a multi-key command whose keys span a slot that is partway through migration. It is transient: retrying shortly usually succeeds once the slot settles.
Sourcepub fn is_clusterdown(&self) -> bool
pub fn is_clusterdown(&self) -> bool
Returns true if this is a CLUSTERDOWN error (cluster).
The cluster cannot currently serve the request – typically a master election window, or a hash slot that no node is serving. It is transient: a topology refresh plus a bounded retry usually recovers.
Sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Returns true if this is a LOADING error.
The node is still loading its dataset into memory (for example just after a restart or a full resync). It is transient: retrying shortly, or against another node, usually succeeds.
Sourcepub fn is_readonly(&self) -> bool
pub fn is_readonly(&self) -> bool
Returns true if this is a READONLY error (writing to replica).
Sourcepub fn server_error_prefix(&self) -> Option<&str>
pub fn server_error_prefix(&self) -> Option<&str>
Returns the Redis error prefix (e.g., “WRONGTYPE”, “NOSCRIPT”, “ERR”).
Sourcepub fn is_connection_error(&self) -> bool
pub fn is_connection_error(&self) -> bool
Returns true if the connection is broken and needs to be replaced.
Trait Implementations§
Source§impl Debug for RedisError
impl Debug for RedisError
Source§impl Display for RedisError
impl Display for RedisError
Source§impl Error for RedisError
impl Error for RedisError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for RedisError
impl From<Error> for RedisError
Source§fn from(source: Error) -> RedisError
fn from(source: Error) -> RedisError
Source§impl From<Error> for RedisError
The blanket conversion used by ?. Produces a RedisError::Connection
with no address; use RedisError::connection at connect sites to record
the address the attempt failed against.
impl From<Error> for RedisError
The blanket conversion used by ?. Produces a RedisError::Connection
with no address; use RedisError::connection at connect sites to record
the address the attempt failed against.