pub enum DbError {
UnsupportedUrl(UnsupportedUrl),
Sqlx(Error),
Migrate(MigrateError),
InvalidData {
what: &'static str,
reason: String,
},
QueryTimeout(Duration),
CommitUnknown,
TransactionFailed,
NotLeading,
}Expand description
Why a database operation failed.
Variants§
UnsupportedUrl(UnsupportedUrl)
The URL doesn’t name a supported database.
Sqlx(Error)
A query or connection failed.
Migrate(MigrateError)
Applying migrations failed.
InvalidData
Stored data doesn’t read back as the model (written by hand, or by an incompatible version).
QueryTimeout(Duration)
A query took longer than the limit (Database::connect_with_timeout): cut off here.
CommitUnknown
The COMMIT of a Database::atomically transaction was cut off by the time limit or
lost with its connection: whether the transaction is stored isn’t known (read it back).
TransactionFailed
A statement of a Database::atomically transaction failed or was cut off, though the
work went on: the transaction was rolled back, nothing of it stored.
NotLeading
A master’s write found the lease no longer its own (another master took it over): it
was refused, nothing of it stored (Database::fenced).
Implementations§
Source§impl DbError
impl DbError
Sourcepub fn from_commit(error: Self) -> Self
pub fn from_commit(error: Self) -> Self
What a failed COMMIT means: refused by the database (a constraint checked at commit,
a serialization failure: rolled back, the error as it is), or cut off or its connection
lost (Self::CommitUnknown: it may be stored).
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Whether the database couldn’t be reached for now, so a role starting should wait and try again rather than exit (the user, 2026-11-15, after B247): a time limit (a query’s, or the pool’s wait for a connection), a connection refused, reset or lost, a pool closed, or Postgres saying it can’t take connections yet (starting up, shutting down, too many connections, a connection exception). Not a wrong URL, password or TLS setting, a schema to migrate or anything about data: those fail the same way again.
Sourcepub fn waiting_reason(&self) -> String
pub fn waiting_reason(&self) -> String
What a role waiting for its database says about this error: no text the database server wrote (it may name the user: “too many connections for role …”), only the error’s kind or code (the user, 2026-11-15: the warning names only the host).
Sourcepub fn is_data_fault(&self) -> bool
pub fn is_data_fault(&self) -> bool
Whether this is about the data a statement touched (stored data that won’t read, a statement the database refuses for its data: a constraint, a trigger), not the database’s own trouble (unreachable, a time limit, its own statement limit, a deadlock or serialization failure, a lock it couldn’t get, an operator’s shutdown, a busy SQLite, a full disk) or the lease: retrying the same statement fails the same way, while other statements may go through.
Trait Implementations§
Source§impl Error for DbError
impl Error for DbError
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()
Source§impl From<DbError> for SecretsError
impl From<DbError> for SecretsError
Source§impl From<UnsupportedUrl> for DbError
impl From<UnsupportedUrl> for DbError
Source§fn from(source: UnsupportedUrl) -> Self
fn from(source: UnsupportedUrl) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for DbError
impl !UnwindSafe for DbError
impl Freeze for DbError
impl Send for DbError
impl Sync for DbError
impl Unpin for DbError
impl UnsafeUnpin for DbError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more