Skip to main content

citadel_sql/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, SqlError>;
4
5#[derive(Debug, Error)]
6pub enum SqlError {
7    #[error("parse error: {0}")]
8    Parse(String),
9
10    #[error("table '{0}' not found")]
11    TableNotFound(String),
12
13    #[error("table '{0}' already exists")]
14    TableAlreadyExists(String),
15
16    #[error("column '{0}' not found")]
17    ColumnNotFound(String),
18
19    #[error("duplicate primary key")]
20    DuplicateKey,
21
22    #[error("NOT NULL constraint failed: {0}")]
23    NotNullViolation(String),
24
25    #[error("type mismatch: expected {expected}, got {got}")]
26    TypeMismatch { expected: String, got: String },
27
28    #[error("primary key required")]
29    PrimaryKeyRequired,
30
31    #[error("duplicate column: {0}")]
32    DuplicateColumn(String),
33
34    #[error("row too large: encoded size {size} exceeds limit {max}")]
35    RowTooLarge { size: usize, max: usize },
36
37    #[error("key too large: encoded size {size} exceeds limit {max}")]
38    KeyTooLarge { size: usize, max: usize },
39
40    #[error("unsupported: {0}")]
41    Unsupported(String),
42
43    #[error("invalid value: {0}")]
44    InvalidValue(String),
45
46    #[error("division by zero")]
47    DivisionByZero,
48
49    #[error("integer overflow")]
50    IntegerOverflow,
51
52    #[error("column '{0}' is ambiguous")]
53    AmbiguousColumn(String),
54
55    #[error("index '{0}' not found")]
56    IndexNotFound(String),
57
58    #[error("index '{0}' already exists")]
59    IndexAlreadyExists(String),
60
61    #[error("unique constraint violated on index '{0}'")]
62    UniqueViolation(String),
63
64    #[error("transaction already active")]
65    TransactionAlreadyActive,
66
67    #[error("no active transaction")]
68    NoActiveTransaction,
69
70    #[error("subquery must return exactly one column")]
71    SubqueryMultipleColumns,
72
73    #[error("scalar subquery returned more than one row")]
74    SubqueryMultipleRows,
75
76    #[error("parameter count mismatch: expected {expected}, got {got}")]
77    ParameterCountMismatch { expected: usize, got: usize },
78
79    #[error("storage error: {0}")]
80    Storage(#[from] citadel_core::Error),
81}