drizzle_core/
error.rs

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