pub enum Error {
Show 20 variants
Connection(String),
ConnectionClosed,
Authentication(AuthError),
Tls(String),
Protocol(String),
Codec(CodecError),
Type(TypeError),
Query(String),
Server {
number: i32,
class: u8,
state: u8,
message: String,
server: Option<String>,
procedure: Option<String>,
line: u32,
},
Transaction(String),
Config(String),
ConnectTimeout,
TlsTimeout,
ConnectionTimeout,
CommandTimeout,
Routing {
host: String,
port: u16,
},
TooManyRedirects {
max: u8,
},
Io(Arc<Error>),
InvalidIdentifier(String),
PoolExhausted,
}Expand description
Errors that can occur during client operations.
Variants§
Connection(String)
Connection failed.
ConnectionClosed
Connection closed unexpectedly.
Authentication(AuthError)
Authentication failed.
Tls(String)
TLS error (string for flexibility in connection code).
Protocol(String)
Protocol error (string for flexibility in connection code).
Codec(CodecError)
Codec error.
Type(TypeError)
Type conversion error.
Query(String)
Query execution error.
Server
Server returned an error.
Fields
Transaction(String)
Transaction error.
Config(String)
Configuration error.
ConnectTimeout
TCP connection timeout occurred.
TlsTimeout
TLS handshake timeout occurred.
ConnectionTimeout
Connection timeout occurred (alias for backwards compatibility).
CommandTimeout
Command execution timeout occurred.
Routing
Connection routing required (Azure SQL).
TooManyRedirects
Too many redirects during connection.
Io(Arc<Error>)
IO error (wrapped in Arc for Clone support).
InvalidIdentifier(String)
Invalid identifier (potential SQL injection attempt).
PoolExhausted
Connection pool exhausted.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Check if this error is transient and may succeed on retry.
Transient errors include timeouts, connection issues, and certain server errors that may resolve themselves.
Per ADR-009, the following server error codes are considered transient:
- 1205: Deadlock victim
- -2: Timeout
- 10928, 10929: Resource limit (Azure)
- 40197: Service error (Azure)
- 40501: Service busy (Azure)
- 40613: Database unavailable (Azure)
- 49918, 49919, 49920: Cannot process request (Azure)
- 4060: Cannot open database (may be transient during failover)
- 18456: Login failed (may be transient in Azure during failover)
Sourcepub fn is_transient_server_error(number: i32) -> bool
pub fn is_transient_server_error(number: i32) -> bool
Check if a server error number is transient (may succeed on retry).
This follows the error codes specified in ADR-009.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if this is a terminal error that will never succeed on retry.
Terminal errors include syntax errors, constraint violations, and other errors that indicate programmer error or data issues.
Per ADR-009, the following server error codes are terminal:
- 102: Syntax error
- 207: Invalid column
- 208: Invalid object
- 547: Constraint violation
- 2627: Unique constraint violation
- 2601: Duplicate key
Sourcepub fn is_terminal_server_error(number: i32) -> bool
pub fn is_terminal_server_error(number: i32) -> bool
Check if a server error number is terminal (will never succeed on retry).
This follows the error codes specified in ADR-009.
Sourcepub fn is_protocol_error(&self) -> bool
pub fn is_protocol_error(&self) -> bool
Check if this error indicates a protocol/driver bug.
Protocol errors typically indicate a bug in the driver implementation rather than a user error or server issue.
Sourcepub fn is_server_error(&self, number: i32) -> bool
pub fn is_server_error(&self, number: i32) -> bool
Check if this is a server error with a specific number.