#[non_exhaustive]pub enum PgError {
Show 18 variants
Server(Box<PgServerError>),
Protocol(ProtocolError),
Transport(TransportError),
Auth(String),
TypeConversion(Error),
Config(String),
ConnectionClosed,
UnexpectedNull {
column: String,
},
ColumnNotFound {
name: String,
},
ColumnIndexOutOfBounds {
index: usize,
count: usize,
},
Timeout,
Pool(PoolErrorVariant),
InvalidState(String),
Unsupported(String),
Cancelled,
Io(Error),
Tls(Error),
Other(String),
}Expand description
The main error type for the PostgreSQL client.
This enum distinguishes between different error categories:
- Server errors — PostgreSQL returned an
ErrorResponsemessage with structured fields (SQLSTATE code, severity, detail, hint, etc.). - Transport errors — Network-level failures (connection refused, timeout, TLS handshake failure, etc.).
- Protocol errors — Wire protocol violations (unexpected message, bad encoding).
- Authentication errors — Failed authentication (wrong password, unsupported method).
- Type conversion errors — Failed conversion between Rust and PostgreSQL types.
- Configuration errors — Invalid connection string or parameters.
- Connection state errors — Connection closed, wrong state for operation.
- Column/row errors — Column not found, index out of bounds, unexpected NULL.
- Timeout — Operation timed out.
- Pool errors — Connection pool exhaustion or management errors.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Server(Box<PgServerError>)
Error returned by the PostgreSQL server (ErrorResponse).
Contains all fields from the ErrorResponse message: severity, SQLSTATE code, message, detail, hint, position, constraint, etc.
Boxed to reduce the overall size of the enum since PgServerError
contains many String and Option fields.
Protocol(ProtocolError)
Wire protocol violation.
Transport(TransportError)
Network/transport error.
Auth(String)
Authentication failure.
TypeConversion(Error)
Type conversion error.
Config(String)
Configuration error (invalid connection string, missing required field, etc.).
ConnectionClosed
Connection is closed.
UnexpectedNull
Unexpected NULL value in a column that was expected to be non-null.
ColumnNotFound
Column not found in the result set.
ColumnIndexOutOfBounds
Column index out of bounds.
Timeout
Operation timed out.
Pool(PoolErrorVariant)
Connection pool error.
InvalidState(String)
Invalid connection state for the requested operation.
Unsupported(String)
The operation is not supported.
Cancelled
Operation was cancelled.
Io(Error)
I/O error.
Tls(Error)
TLS error.
Other(String)
Any other error not covered by the above variants.
Implementations§
Source§impl PgError
impl PgError
Sourcepub fn is_connection_broken(&self) -> bool
pub fn is_connection_broken(&self) -> bool
Check if the error indicates the connection is broken and cannot be recovered without reconnecting.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is potentially retryable without reconnecting.
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()