1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, QueryError>;
4
5#[derive(Debug, Error)]
6pub enum QueryError {
7 #[error("Database error: {0}")]
8 Database(String),
9
10 #[error("Schema error: {0}")]
11 Schema(String),
12
13 #[error("Serialization error: {0}")]
14 Serialization(String),
15
16 #[error("Type mapping error: {0}")]
17 TypeMapping(String),
18
19 #[error("Sync error: {0}")]
20 Sync(String),
21
22 #[error("Query error: {0}")]
23 Query(String),
24
25 #[error("Connection error: {0}")]
26 Connection(String),
27
28 #[error("Transaction error: {0}")]
29 Transaction(String),
30
31 #[error("Migration error: {0}")]
32 Migration(String),
33
34 #[error("Component not registered: {0}")]
35 ComponentNotRegistered(String),
36
37 #[error("IO error: {0}")]
38 Io(#[from] std::io::Error),
39
40 #[error("JSON error: {0}")]
41 Json(#[from] serde_json::Error),
42
43 #[cfg(feature = "postgres")]
44 #[error("SQLx error: {0}")]
45 Sqlx(#[from] sqlx::Error),
46}
47
48impl From<tx2_link::LinkError> for QueryError {
49 fn from(err: tx2_link::LinkError) -> Self {
50 QueryError::Serialization(err.to_string())
51 }
52}