drizzle_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum DrizzleError {
5    /// Error executing a query
6    #[error("Execution error: {0}")]
7    ExecutionError(String),
8
9    /// Error preparing a statement
10    #[error("Prepare error: {0}")]
11    PrepareError(String),
12
13    /// No rows returned when at least one was expected
14    #[error("No rows found")]
15    NotFound,
16
17    /// Error with transaction
18    #[error("Transaction error: {0}")]
19    TransactionError(String),
20
21    /// Error mapping data
22    #[error("Mapping error: {0}")]
23    Mapping(String),
24
25    /// Error in statement
26    #[error("Statement error: {0}")]
27    Statement(String),
28
29    /// Error in query
30    #[error("Query error: {0}")]
31    Query(String),
32
33    /// Error converting parameters (e.g. JSON serialization failure)
34    #[error("Parameter conversion error: {0}")]
35    ParameterError(String),
36
37    /// Integer conversion error
38    #[error("Integer conversion error: {0}")]
39    TryFromInt(#[from] std::num::TryFromIntError),
40
41    /// Parse int error
42    #[error("Parse int error: {0}")]
43    ParseInt(#[from] std::num::ParseIntError),
44
45    /// Parse float error
46    #[error("Parse float error: {0}")]
47    ParseFloat(#[from] std::num::ParseFloatError),
48
49    /// Parse bool error
50    #[error("Parse bool error: {0}")]
51    ParseBool(#[from] std::str::ParseBoolError),
52
53    /// Type conversion error
54    #[error("Type conversion error: {0}")]
55    ConversionError(String),
56
57    /// Generic error
58    #[error("Database error: {0}")]
59    Other(String),
60
61    /// Rusqlite specific errors
62    #[cfg(feature = "rusqlite")]
63    #[error("Rusqlite error: {0}")]
64    Rusqlite(#[from] rusqlite::Error),
65
66    /// Turso specific errors
67    #[cfg(feature = "turso")]
68    #[error("Turso error: {0}")]
69    Turso(#[from] turso::Error),
70
71    /// LibSQL specific errors
72    #[cfg(feature = "libsql")]
73    #[error("LibSQL error: {0}")]
74    LibSQL(#[from] libsql::Error),
75
76    /// UUID parsing error
77    #[cfg(feature = "uuid")]
78    #[error("UUID error: {0}")]
79    UuidError(#[from] uuid::Error),
80
81    /// JSON serialization/deserialization error
82    #[cfg(feature = "serde")]
83    #[error("JSON error: {0}")]
84    JsonError(#[from] serde_json::Error),
85
86    /// Infallible conversion error (should never happen)
87    #[error("Infallible conversion error")]
88    Infallible(#[from] std::convert::Infallible),
89}
90
91/// Result type for database operations
92pub type Result<T> = std::result::Result<T, DrizzleError>;