#[non_exhaustive]pub enum DbError {
Sqlx(Error),
Build(String),
BackendDisabled(Dialect),
NoBackend,
BadUrl,
LockTimeout {
waited_secs: u64,
},
}Expand description
A database error. Its text may contain SQL or driver details: it is for logs only; handlers
turn it into a generic internal answer (AppError).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Sqlx(Error)
An error from sqlx (connection, query, decoding).
Build(String)
A sea-query statement could not be built.
BackendDisabled(Dialect)
The URL names a backend whose feature is not compiled in.
NoBackend
No backend is compiled in at all.
BadUrl
The URL is empty or its scheme is not recognised.
LockTimeout
Another process holds the migrations lock of this database.
Implementations§
Source§impl DbError
impl DbError
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
A one-line description for operators: for a database error the server’s message and code (SQLSTATE / MySQL error number), without the driver’s decorations.
Sourcepub fn is_unique_violation(&self) -> bool
pub fn is_unique_violation(&self) -> bool
Whether this is a unique-constraint violation (e.g. a duplicate email), on every backend.
Sourcepub fn is_foreign_key_violation(&self) -> bool
pub fn is_foreign_key_violation(&self) -> bool
Whether this is a foreign-key violation, on every backend.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the database aborted the transaction to resolve a conflict between concurrent
transactions, so that running the whole transaction again may succeed: a deadlock (MySQL
error 1213, SQLSTATE 40001; PostgreSQL 40P01), a serialization failure (PostgreSQL
40001) or a busy / locked SQLite database. A lock-wait timeout (MySQL 1205) is not
retryable (another wait would only add to it).
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()
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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