pub enum PgError {
Connection(String),
Protocol(String),
Auth(String),
Query(String),
QueryServer(PgServerError),
NoRows,
Io(Error),
Encode(String),
Timeout(String),
PoolExhausted {
max: usize,
},
PoolClosed,
}Expand description
Error type for PostgreSQL driver operations.
Variants§
Connection(String)
TCP / TLS connection failure with the PostgreSQL server.
Protocol(String)
Wire-protocol framing or decoding error.
Auth(String)
Authentication failure (bad password, unsupported mechanism, etc.).
Query(String)
Query execution error returned by the backend (e.g. constraint violation).
QueryServer(PgServerError)
Structured server error with SQLSTATE and optional detail/hint fields.
NoRows
The query returned zero rows when at least one was expected.
Io(Error)
I/O error (preserves inner error for chaining)
Encode(String)
Encoding error (parameter limit, etc.)
Timeout(String)
Operation timed out (connection, acquire, query)
PoolExhausted
Pool exhausted — all connections are in use
PoolClosed
Pool is closed and no longer accepting requests
Implementations§
Source§impl PgError
impl PgError
Sourcepub fn server_error(&self) -> Option<&PgServerError>
pub fn server_error(&self) -> Option<&PgServerError>
Return structured server error fields when available.
Sourcepub fn is_prepared_statement_retryable(&self) -> bool
pub fn is_prepared_statement_retryable(&self) -> bool
True when a cached prepared statement can be self-healed by clearing local statement state and retrying once.
Sourcepub fn is_prepared_statement_already_exists(&self) -> bool
pub fn is_prepared_statement_already_exists(&self) -> bool
True when server reports the prepared statement name already exists.
This typically means local cache eviction drifted from server state (e.g. local entry dropped while backend statement still exists). Callers can retry once without Parse after preserving local mapping.
Sourcepub fn is_transient_server_error(&self) -> bool
pub fn is_transient_server_error(&self) -> bool
True when the error is a transient server condition that may succeed on retry. Covers serialization failures, deadlocks, standby unavailability, connection exceptions, and prepared-statement staleness.
Callers should pair this with a bounded retry loop and backoff.
Trait Implementations§
Source§impl Error for PgError
impl Error for PgError
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()