#[non_exhaustive]pub enum DbError {
Show 19 variants
ConnectionError(String),
QueryError(String),
SqlSyntaxError(String),
ConstraintError(String),
TypeConversionError(String),
SerializationError(String),
DeserializationError(String),
TransactionError(String),
TableNotFound(String),
MissingWhereClause,
RedisConnectionError(String),
RedisCommandError(String),
RedisPoolError(String),
RedisTypeConversionError(String),
RedisTimeoutError(String),
MissingGroupByClause,
UnsupportedOperator(String),
InvalidArgument(String),
Unknown(String),
}Expand description
数据库错误类型
标注 #[non_exhaustive]:未来新增变体不构成跨 crate 破坏性变更(下游 match 需
带 _ 臂)。同 crate 内的穷举 match 不受影响。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
ConnectionError(String)
QueryError(String)
SqlSyntaxError(String)
ConstraintError(String)
TypeConversionError(String)
SerializationError(String)
DeserializationError(String)
TransactionError(String)
TableNotFound(String)
MissingWhereClause
RedisConnectionError(String)
RedisCommandError(String)
RedisPoolError(String)
RedisTypeConversionError(String)
RedisTimeoutError(String)
MissingGroupByClause
UnsupportedOperator(String)
不支持的操作符错误,当传入的操作符不在支持集合中时返回
InvalidArgument(String)
参数非法(调用方过错):批量数据列集不一致、空数据、batch_size 为 0 等。
与 DbError::SerializationError 区分——后者专表「(反)序列化失败」,
此变体专表「入参本身不合法」,便于调用方按变体精确分流(DB-14)。
Unknown(String)
Implementations§
Source§impl DbError
impl DbError
Sourcepub fn code(&self) -> u32
pub fn code(&self) -> u32
稳定错误码(8xxxxx 段,独立于 yang-base 的 BaseError 码命名空间)。
与 DbError::category 同源维护;新增变体需同步补码。
Sourcepub fn category(&self) -> DbErrorCategory
pub fn category(&self) -> DbErrorCategory
引擎级分类。是 DbError::is_retryable 的单一事实源。
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
是否为可重试的瞬时错误(等价 category() == Transient)。
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<Error> for DbError
Available on crate features mysql or postgres only.从 sqlx::Error 转换为 DbError
impl From<Error> for DbError
Available on crate features
mysql or postgres only.从 sqlx::Error 转换为 DbError
Source§impl From<PoolError<RedisError>> for DbError
Available on crate feature redis only.从 deadpool_redis::PoolError 转换为 DbError
impl From<PoolError<RedisError>> for DbError
Available on crate feature
redis only.从 deadpool_redis::PoolError 转换为 DbError
Source§impl From<RedisError> for DbError
Available on crate feature redis only.从 redis::RedisError 转换为 DbError
impl From<RedisError> for DbError
Available on crate feature
redis only.从 redis::RedisError 转换为 DbError
Source§fn from(err: RedisError) -> Self
fn from(err: RedisError) -> Self
Converts to this type from the input type.
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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