pub enum DbError {
DatabaseConnection(String),
DatabaseOperation(String),
DatabaseOperationClassified {
message: String,
kind: DatabaseErrorKind,
},
CommitOutcomeUnknown {
message: String,
kind: Option<DatabaseErrorKind>,
},
RetryExhausted,
NonRetryable(String),
}Expand description
Errors returned by database helpers.
Variants§
DatabaseConnection(String)
A database connection could not be established.
DatabaseOperation(String)
A database query, transaction, or setup operation failed.
DatabaseOperationClassified
A database operation error with a driver-native classification.
CommitOutcomeUnknown
The commit response was lost after the transaction may have been committed.
RetryExhausted
Retry loop exhausted without a final operation error.
NonRetryable(String)
Operation failed with an error that should not be retried.
Implementations§
Source§impl DbError
impl DbError
Sourcepub fn database_connection(error: impl Display) -> Self
pub fn database_connection(error: impl Display) -> Self
Creates a database-connection error from a displayable error.
Sourcepub fn database_operation(error: impl Display) -> Self
pub fn database_operation(error: impl Display) -> Self
Creates a database-operation error from a displayable error.
Sourcepub fn database_operation_classified(
error: impl Display,
kind: DatabaseErrorKind,
) -> Self
pub fn database_operation_classified( error: impl Display, kind: DatabaseErrorKind, ) -> Self
Creates a database-operation error while preserving its driver-native classification.
Sourcepub fn commit_outcome_unknown(
error: impl Display,
kind: Option<DatabaseErrorKind>,
) -> Self
pub fn commit_outcome_unknown( error: impl Display, kind: Option<DatabaseErrorKind>, ) -> Self
Creates an error for a commit whose final server-side outcome is unknown.
Sourcepub fn database_error_kind(&self) -> Option<DatabaseErrorKind>
pub fn database_error_kind(&self) -> Option<DatabaseErrorKind>
Returns the driver-native classification, when one was available.
Sourcepub fn commit_outcome_is_unknown(&self) -> bool
pub fn commit_outcome_is_unknown(&self) -> bool
Returns whether this error came from a commit with an unknown final outcome.
Sourcepub fn non_retryable(error: impl Display) -> Self
pub fn non_retryable(error: impl Display) -> Self
Creates a non-retryable error from a displayable error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns whether the error is considered retryable by retry::with_retry.
Only connection failures and driver-classified transient locking conflicts (deadlock, serialization failure, lock timeout) qualify. Unclassified operation errors are not retried: without a driver classification there is no evidence the operation failed in a retry-safe way, so callers see the failure immediately.
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()
Auto Trait Implementations§
impl Freeze for DbError
impl RefUnwindSafe for DbError
impl Send for DbError
impl Sync for DbError
impl Unpin for DbError
impl UnsafeUnpin for DbError
impl UnwindSafe 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>
§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