pub enum TxError {
NotStarted,
AlreadyStarted,
CommitFailed(String),
RollbackFailed(String),
SavepointError(String),
NestedNotSupported,
NotActive(TransactionState),
InvalidSavepointName(String),
ConnectionTaken,
MaxNestingDepthExceeded {
current_depth: u32,
max_depth: u32,
},
DeadlockDetected {
attempt: u32,
max_attempts: u32,
},
}Expand description
事务特有错误
Variants§
NotStarted
事务未开始
AlreadyStarted
事务已开始
CommitFailed(String)
事务提交失败
RollbackFailed(String)
事务回滚失败
SavepointError(String)
保存点错误
NestedNotSupported
不支持嵌套事务
NotActive(TransactionState)
事务不在 Active 状态(用于 execute/query 等操作前置校验)
InvalidSavepointName(String)
保存点名称非法(包含不支持的字符或以数字开头)
ConnectionTaken
连接已被取走(take_connection 重复调用,或操作时连接已释放)
MaxNestingDepthExceeded
H-8 修复:嵌套事务深度超过限制
current_depth 为当前已嵌套深度(含本次),max_depth 为配置的最大深度。
DeadlockDetected
M-8 修复:死锁检测
当事务执行过程中检测到死锁(数据库返回死锁错误码)时返回。
调用方可使用 retry_on_deadlock 包装器自动重试。
Trait Implementations§
Source§impl Error for TxError
impl Error for TxError
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()
Auto Trait Implementations§
impl Freeze for TxError
impl RefUnwindSafe for TxError
impl Send for TxError
impl Sync for TxError
impl Unpin for TxError
impl UnsafeUnpin for TxError
impl UnwindSafe for TxError
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