#[non_exhaustive]pub enum Error<E> {
Backend(E),
Timeout,
Closed,
InvalidConfig(&'static str),
}std only.Expand description
An error returned by a Pool operation.
The type parameter E is the manager’s own error type
(Manager::Error). A failure that originates inside
the manager — a connection that could not be opened, a transaction that could
not be rolled back — is carried unchanged in Error::Backend, so the caller
can inspect or match on the underlying cause rather than a stringified copy of
it.
The enum is #[non_exhaustive]: future versions may add variants, so a match
on it must include a wildcard arm.
§Examples
Distinguish a saturated pool from a backend failure:
use pool_mod::Error;
use std::convert::Infallible;
fn describe(err: &Error<Infallible>) -> &'static str {
match err {
Error::Timeout => "pool is busy, try again",
Error::Closed => "pool is shut down",
_ => "other",
}
}
assert_eq!(describe(&Error::Timeout), "pool is busy, try again");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Backend(E)
The manager failed to create or recycle a resource. Carries the manager’s own error.
Inspect the inner error to decide whether the failure is transient (worth retrying) or permanent.
Timeout
The configured wait elapsed before a resource became available.
The pool is healthy but saturated. Retry later, raise max_size, or hold
borrowed resources for less time.
Closed
The pool has been shut down with Pool::close.
No further resources will be handed out; this is terminal for the pool.
InvalidConfig(&'static str)
The pool could not be built because its configuration is invalid.
The message names the constraint that was violated (for example, a
max_size of zero).
Trait Implementations§
Source§impl<E> Error for Error<E>where
E: Error + 'static,
impl<E> Error for Error<E>where
E: Error + 'static,
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()