1use thiserror::Error;
10
11pub type Result<T> = std::result::Result<T, Error>;
13
14#[derive(Error, Debug)]
16pub enum Error {
17 #[error("Database error: {0}")]
19 Database(String),
20
21 #[error("Schema inspection error: {0}")]
23 Inspection(String),
24
25 #[error("Migration error: {0}")]
27 Migration(String),
28
29 #[error("Tenant error: {0}")]
31 Tenant(String),
32
33 #[error("Planning error: {0}")]
35 Planning(String),
36
37 #[error("Execution error: {0}")]
39 Execution(String),
40
41 #[error("Snapshot error: {0}")]
43 Snapshot(String),
44
45 #[error("Diff error: {0}")]
47 Diff(String),
48
49 #[error("Validation error: {0}")]
51 Validation(String),
52
53 #[error("IO error: {0}")]
55 Io(#[from] std::io::Error),
56
57 #[error("Serialization error: {0}")]
59 Serialization(#[from] serde_json::Error),
60}
61
62#[cfg(test)]
63mod tests {
64 use super::*;
65
66 #[test]
67 fn test_error_display() {
68 let err = Error::Database("Connection failed".to_string());
69 assert!(err.to_string().contains("Connection failed"));
70 }
71
72 #[test]
73 fn test_error_from_io() {
74 let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "File not found");
75 let err: Error = io_err.into();
76 assert!(err.to_string().contains("File not found"));
77 }
78}