#[non_exhaustive]pub enum DbErr {
Driver(Error),
RecordNotFound(String),
RecordNotInserted,
RecordNotUpdated,
AttrNotSet(String),
PrimaryKeyNotSet,
Type(String),
Json(String),
Migration(String),
Custom(String),
}Expand description
The error returned by every fallible operation of the ORM.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Driver(Error)
An error reported by the driver or the engine.
RecordNotFound(String)
A row was expected but none was found.
RecordNotInserted
An INSERT inserted nothing, for example under ON CONFLICT DO NOTHING.
RecordNotUpdated
An UPDATE matched no row.
AttrNotSet(String)
A required attribute of an active model is NotSet.
PrimaryKeyNotSet
A primary key value is missing from an active model.
Type(String)
A value had the wrong type for the target column or field.
Json(String)
A JSON conversion failed.
Migration(String)
A migration failed.
Custom(String)
A free-form error raised by user code or hooks.
Implementations§
Source§impl DbErr
impl DbErr
Sourcepub fn kind(&self) -> Option<ErrorKind>
pub fn kind(&self) -> Option<ErrorKind>
The classification of the underlying driver error, if any.
ORM-level variants carry no driver classification and yield None.
Sourcepub fn constraint(&self) -> Option<ConstraintKind>
pub fn constraint(&self) -> Option<ConstraintKind>
The violated constraint, when this wraps a constraint error.
Sourcepub fn is_unique_violation(&self) -> bool
pub fn is_unique_violation(&self) -> bool
Whether the error is a unique-key violation.
Sourcepub fn is_foreign_key_violation(&self) -> bool
pub fn is_foreign_key_violation(&self) -> bool
Whether the error is a foreign-key violation.
Trait Implementations§
Source§impl Error for DbErr
impl Error for DbErr
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 DbErr
impl !UnwindSafe for DbErr
impl Freeze for DbErr
impl Send for DbErr
impl Sync for DbErr
impl Unpin for DbErr
impl UnsafeUnpin for DbErr
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<T> ErasedDestructor for Twhere
T: 'static,
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