pub enum DbError {
Connection(String),
Query(String),
Transaction(String),
Pool(String),
Config(String),
Migration(String),
Validation(String),
Io(Error),
Serialization(Error),
}Expand description
数据库模块错误类型
定义了数据库操作中可能出现的所有错误类型。 每种错误类型都包含详细的错误信息。
Variants§
Connection(String)
数据库连接错误
当无法建立数据库连接时发生,可能的原因包括:
- 网络问题
- 认证失败
- 数据库服务未启动
Query(String)
数据库查询错误
执行 SQL 查询时发生的错误,可能的原因包括:
- SQL 语法错误
- 表或字段不存在
- 数据类型不匹配
Transaction(String)
数据库事务错误
在事务处理过程中发生的错误,例如:
- 事务提交失败
- 事务回滚失败
- 事务超时
Pool(String)
数据库连接池错误
连接池管理相关的错误,例如:
- 连接池已满
- 无法创建新连接
- 连接获取超时
Config(String)
数据库配置错误
配置相关的错误,例如:
- 配置参数无效
- 必要配置缺失
- 配置格式错误
Migration(String)
数据库迁移错误
数据库架构迁移过程中的错误,例如:
- 迁移脚本执行失败
- 版本冲突
- 回滚失败
Validation(String)
数据库验证错误
数据验证相关的错误,例如:
- 字段值不符合约束条件
- 数据完整性检查失败
Io(Error)
IO 错误
文件操作相关的错误
Serialization(Error)
序列化错误
JSON 数据序列化/反序列化过程中的错误
Trait Implementations§
Source§impl Error for DbError
impl Error for DbError
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 !RefUnwindSafe for DbError
impl !UnwindSafe for DbError
impl Freeze 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
Mutably borrows from an owned value. Read more
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>
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