Skip to main content

dbkit_rs/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum DbkitError {
5    #[error("failed to create connection pool: {0}")]
6    PoolCreation(String),
7
8    #[error("connection error: {0}")]
9    Connection(String),
10
11    #[error("authentication failed")]
12    AuthFailed,
13
14    #[error("too many connections")]
15    TooManyConnections,
16
17    #[error("database '{name}' does not exist and auto-create failed: {reason}")]
18    DatabaseCreation { name: String, reason: String },
19
20    #[error("postgres error: {0}")]
21    Postgres(#[from] tokio_postgres::Error),
22
23    #[error("pool error: {0}")]
24    Pool(String),
25
26    #[cfg(feature = "duckdb")]
27    #[error("DuckDB not initialized — call BaseHandler::with_duckdb()")]
28    DuckDbNotInitialized,
29
30    #[cfg(feature = "duckdb")]
31    #[error("DuckDB error: {0}")]
32    DuckDb(String),
33
34    #[error("expected {expected} row(s), got {actual}")]
35    RowCount { expected: String, actual: usize },
36
37    #[cfg(feature = "duckdb")]
38    #[error("lock poisoned: {0}")]
39    LockPoisoned(String),
40
41    #[cfg(feature = "duckdb")]
42    #[error("task join error: {0}")]
43    TaskJoin(String),
44
45    #[error("migration failed: {0}")]
46    Migration(String),
47}