toolu_orm_connection/error.rs
1//! DbError enum for connection-layer errors across all backends.
2
3use toolu_orm_core::error::DbCoreError;
4
5/// Errors produced by database connection operations.
6///
7/// This enum covers all failure modes across all backends (libsql, rusqlite, postgres).
8/// Backend-specific errors are stringified into the appropriate variant.
9#[derive(Debug, thiserror::Error)]
10pub enum DbError {
11 /// Connection establishment or configuration failure.
12 #[error("connection failed: {0}")]
13 Connection(String),
14
15 /// SQL execution or query failure.
16 #[error("query failed: {0}")]
17 Query(String),
18
19 /// Transaction begin/commit/rollback failure.
20 #[error("transaction failed: {0}")]
21 Transaction(String),
22
23 /// Connection pool exhaustion or management failure.
24 #[error("pool error: {0}")]
25 Pool(String),
26
27 /// Row-to-struct mapping failure (type mismatch, missing column).
28 #[error("row mapping failed: {0}")]
29 RowMapping(String),
30}
31
32impl From<DbCoreError> for DbError {
33 fn from(e: DbCoreError) -> Self {
34 DbError::RowMapping(e.to_string())
35 }
36}