1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum VeritableError {
5 #[error("Config error: {0}")]
6 Config(String),
7 #[error("Connectivity error: {0}")]
8 Connectivity(String),
9 #[error("Engine error: {0}")]
10 Engine(String),
11 #[error("Query error: {0}")]
12 Query(String),
13 #[error("Schema error: {0}")]
14 Schema(String),
15}
16
17pub type Result<T> = std::result::Result<T, VeritableError>;
18
19impl VeritableError {
20 pub fn exit_code(&self) -> u8 {
22 match self {
23 VeritableError::Config(_) => 1,
24 VeritableError::Connectivity(_) => 2,
25 VeritableError::Engine(_) => 3,
26 VeritableError::Query(_) => 4,
27 VeritableError::Schema(_) => 5,
28 }
29 }
30}