pub struct Error { /* private fields */ }Expand description
Implementations§
Source§impl Error
impl Error
Sourcepub fn into_kind(self) -> ErrorKind
pub fn into_kind(self) -> ErrorKind
Consumes the error and yields its kind, for matching by value.
Sourcepub fn context(&self) -> Option<&ErrorContext>
pub fn context(&self) -> Option<&ErrorContext>
The command the error belongs to, when the client knows it.
None for an error raised outside any command, such as a connection
timeout.
Sourcepub fn command(&self) -> Option<&str>
pub fn command(&self) -> Option<&str>
The name of the command the error belongs to — shorthand for
context().map(ErrorContext::command).
Sourcepub fn is_connection_error(&self) -> bool
pub fn is_connection_error(&self) -> bool
Whether the connection to the server is what failed: the transport broke, the peer went away, or a reply could not be framed.
True for a transport or TLS failure, an end of stream, a disconnection,
the loss of the network task, and a RESP framing failure — the last one
because a stream the parser lost track of cannot carry another command,
so the client drops the connection and reconnects. False for anything the
server answered (is_server_error), for a
timeout (is_timeout), and for a decode failure on
a well-framed reply, which fails one command only.
The command may or may not have run: the answer, if any, was lost with the connection.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Whether a deadline expired before the operation completed.
Covers both Config::connect_timeout
and Config::command_timeout;
command tells them apart, being None for a
connection that never got to send anything. A blocking command reaching
its own server-side timeout is not an error at all — it replies nil, so
it arrives as None.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Whether the server answered, and answered an error.
The connection is healthy and the command reached the server: what
failed is the command itself — a wrong type, a missing script, a refused
authentication. Match on
RedisError::kind for the exact code.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the failure is transient, so that sending the command again may succeed.
True for every connection error, for a
timeout, and for the server codes that ask for a
replay: TRYAGAIN, CLUSTERDOWN, MASTERDOWN and NOMASTERLINK.
§Warning
Transient does not mean the command did not run. A connection that dies
or a deadline that expires after the server applied the write leaves no
way to tell it apart from one that died before. Replay only commands
that are safe to apply twice, or make them idempotent first — INCR
replayed on a lost reply counts twice.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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 Error for Error
impl Error for Error
Source§fn custom<T>(msg: T) -> Selfwhere
T: Display,
fn custom<T>(msg: T) -> Selfwhere
T: Display,
Source§fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize receives a type different from what it was
expecting. Read moreSource§fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize receives a value of the right type but that
is wrong for some other reason. Read moreSource§fn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Source§fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Deserialize enum type received a variant with an
unrecognized name.Source§fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Deserialize struct type received a field with an
unrecognized name.Source§fn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Deserialize struct type expected to receive a required
field with a particular name but that field was not present in the
input.Source§fn duplicate_field(field: &'static str) -> Self
fn duplicate_field(field: &'static str) -> Self
Deserialize struct type received more than one of the
same field.Source§impl From<ClientError> for Error
impl From<ClientError> for Error
Source§fn from(value: ClientError) -> Self
fn from(value: ClientError) -> Self
Source§impl From<FromUtf8Error> for Error
impl From<FromUtf8Error> for Error
Source§fn from(value: FromUtf8Error) -> Self
fn from(value: FromUtf8Error) -> Self
Source§impl From<InvalidDnsNameError> for Error
Available on crate feature rustls only.
impl From<InvalidDnsNameError> for Error
rustls only.