#[non_exhaustive]pub enum Error {
Show 18 variants
Io(Error),
Protocol(String),
Server(Box<ServerError>),
Auth(String),
Tls(String),
Pool(String),
Config(String),
Encode(String),
Decode(String),
ColumnNotFound(String),
ColumnIndex {
index: usize,
count: usize,
},
UnexpectedNull(usize),
Timeout(String),
ConnectionClosed,
Copy(String),
TransactionCompleted,
AllHostsFailed(String),
WrongSessionAttrs(String),
}Expand description
All possible errors returned by sentinel-driver.
§Stability contract
This enum is #[non_exhaustive] as of v1.1.0. New variants may be
added in any future minor release without a major version bump, in
line with the additive-only stability policy in GOVERNANCE.md.
What this means for downstream code:
?propagation andFrom/Intoconversion are unaffected.- Manual exhaustive
matcharms must include a wildcard_ =>arm to keep compiling against future minor releases. This is the only migration required by the v1.0 → v1.1 transition.
// OK — has a wildcard arm.
match err {
Error::ConnectionClosed => /* ... */,
Error::TransactionCompleted => /* ... */,
_ => /* ... */,
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io(Error)
I/O error from TCP/TLS stream.
Protocol(String)
PostgreSQL protocol error (unexpected message, malformed packet, etc.).
Server(Box<ServerError>)
Error returned by the PostgreSQL server.
Auth(String)
Authentication failure.
Tls(String)
TLS/SSL negotiation error.
Pool(String)
Connection pool error.
Config(String)
Invalid configuration.
Encode(String)
Type encoding error (Rust → PG).
Decode(String)
Type decoding error (PG → Rust).
ColumnNotFound(String)
Column not found by name.
ColumnIndex
Column index out of bounds.
UnexpectedNull(usize)
Unexpected null value.
Timeout(String)
Timeout (connect, query, pool checkout).
ConnectionClosed
Connection is closed or broken.
Copy(String)
COPY protocol error.
TransactionCompleted
Transaction already completed (committed or rolled back).
AllHostsFailed(String)
All configured hosts failed to connect.
WrongSessionAttrs(String)
Connected server does not match required session attributes.
Implementations§
Source§impl Error
impl Error
Sourcepub fn server_error(&self) -> Option<&ServerError>
pub fn server_error(&self) -> Option<&ServerError>
Returns the server error details if this is a server error.
Sourcepub fn is_unique_violation(&self) -> bool
pub fn is_unique_violation(&self) -> bool
Returns true if this error represents a unique violation (SQLSTATE 23505).
Sourcepub fn is_foreign_key_violation(&self) -> bool
pub fn is_foreign_key_violation(&self) -> bool
Returns true if this error represents a foreign key violation (SQLSTATE 23503).
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()