Skip to main content

dbkit/
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("unsupported database backend: {0}")]
21    UnsupportedBackend(String),
22
23    #[error("database error: {0}")]
24    Sqlx(#[from] sqlx::Error),
25
26    #[error("pool error: {0}")]
27    Pool(String),
28
29    #[cfg(feature = "duckdb")]
30    #[error("DuckDB not initialized — call BaseHandler::with_duckdb()")]
31    DuckDbNotInitialized,
32
33    #[cfg(feature = "duckdb")]
34    #[error("DuckDB error: {0}")]
35    DuckDb(String),
36
37    #[cfg(feature = "datafusion")]
38    #[error("DataFusion error: {0}")]
39    DataFusion(String),
40
41    #[error("no analytical read engine configured")]
42    NoReadEngine,
43
44    #[error("remote source error: {0}")]
45    Remote(String),
46
47    #[error("type conversion error: {0}")]
48    Conversion(String),
49
50    #[error("expected {expected} row(s), got {actual}")]
51    RowCount { expected: String, actual: usize },
52
53    #[cfg(feature = "duckdb")]
54    #[error("lock poisoned: {0}")]
55    LockPoisoned(String),
56
57    #[cfg(feature = "duckdb")]
58    #[error("task join error: {0}")]
59    TaskJoin(String),
60
61    #[error("migration failed: {0}")]
62    Migration(String),
63
64    #[error("invalid argument: {0}")]
65    InvalidArgument(String),
66}