pub enum DbError {
Internal(String),
MappingError(String),
UniqueViolation(String),
ForeignKeyViolation(String),
NotFound,
Sqlx(Error),
}Expand description
Database failure, safe to log (MAIR-290).
Its Display and Debug describe the failure by its type and context (SQLSTATE,
constraint, table, column), never by the values involved. A Postgres message can carry them: 22P02 quotes the invalid input, a RAISE formats its
parameters, and the DETAIL of a check or not-null violation lists the whole failing row
(e-mail, phone, password hash…). The variants keep their shape, so the APIs can still match
on DbError::Sqlx(sqlx::Error::Database(_)) and read the code; do not log that inner error
yourself.
Variants§
Internal(String)
MappingError(String)
The row could not be read as the DTO: the serde message, without the value (see
describe_json_error).
UniqueViolation(String)
The name of the unique constraint that refused the write.
ForeignKeyViolation(String)
The name of the foreign key that refused the write.
NotFound
Sqlx(Error)
Implementations§
Trait Implementations§
Source§impl Error for DbError
impl Error for DbError
1.30.0 · 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 ApiLibError
impl From<DbError> for ApiLibError
Source§impl ResponseError for DbError
impl ResponseError for DbError
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Source§fn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Auto Trait Implementations§
impl !RefUnwindSafe for DbError
impl !UnwindSafe for DbError
impl Forget for DbError
impl Freeze for DbError
impl Move 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
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToEcoString for T
impl<T> ToEcoString for T
Source§fn to_eco_string(&self) -> EcoString
fn to_eco_string(&self) -> EcoString
EcoString.