Skip to main content

vespertide_planner/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum PlannerError {
5    #[error("table already exists: {0}")]
6    TableExists(String),
7    #[error("table not found: {0}")]
8    TableNotFound(String),
9    #[error("column already exists: {0}.{1}")]
10    ColumnExists(String, String),
11    #[error("column not found: {0}.{1}")]
12    ColumnNotFound(String, String),
13    #[error("index not found: {0}.{1}")]
14    IndexNotFound(String, String),
15    #[error("duplicate table name: {0}")]
16    DuplicateTableName(String),
17    #[error("foreign key references non-existent table: {0}.{1} -> {2}")]
18    ForeignKeyTableNotFound(String, String, String),
19    #[error("foreign key references non-existent column: {0}.{1} -> {2}.{3}")]
20    ForeignKeyColumnNotFound(String, String, String, String),
21    #[error("index references non-existent column: {0}.{1} -> {2}")]
22    IndexColumnNotFound(String, String, String),
23    #[error("constraint references non-existent column: {0}.{1} -> {2}")]
24    ConstraintColumnNotFound(String, String, String),
25    #[error("constraint has empty column list: {0}.{1}")]
26    EmptyConstraintColumns(String, String),
27    #[error("AddColumn requires fill_with when column is NOT NULL without default: {0}.{1}")]
28    MissingFillWith(String, String),
29    #[error("table validation error: {0}")]
30    TableValidation(String),
31    #[error("table '{0}' must have a primary key")]
32    MissingPrimaryKey(String),
33    #[error("enum '{0}' in column '{1}.{2}' has duplicate variant name: '{3}'")]
34    DuplicateEnumVariantName(String, String, String, String),
35    #[error("enum '{0}' in column '{1}.{2}' has duplicate value: {3}")]
36    DuplicateEnumValue(String, String, String, i32),
37    #[error("{0}")]
38    InvalidEnumDefault(#[from] Box<InvalidEnumDefaultError>),
39}
40
41#[derive(Debug, Error)]
42#[error(
43    "enum '{enum_name}' in column '{table_name}.{column_name}' has invalid {value_type} value '{value}': not in allowed values [{allowed}]"
44)]
45pub struct InvalidEnumDefaultError {
46    pub enum_name: String,
47    pub table_name: String,
48    pub column_name: String,
49    pub value_type: String,
50    pub value: String,
51    pub allowed: String,
52}