Skip to main content

kimberlite_query/
error.rs

1//! Error types for query operations.
2
3use kimberlite_store::StoreError;
4
5/// Errors that can occur during query parsing and execution.
6#[derive(thiserror::Error, Debug)]
7pub enum QueryError {
8    /// SQL syntax or parsing error.
9    #[error("parse error: {0}")]
10    ParseError(String),
11
12    /// Table not found in schema.
13    #[error("table '{0}' not found")]
14    TableNotFound(String),
15
16    /// Column not found in table.
17    #[error("column '{column}' not found in table '{table}'")]
18    ColumnNotFound { table: String, column: String },
19
20    /// Query parameter not provided.
21    #[error("parameter ${0} not provided")]
22    ParameterNotFound(usize),
23
24    /// Type mismatch between expected and actual value.
25    #[error("type mismatch: expected {expected}, got {actual}")]
26    TypeMismatch { expected: String, actual: String },
27
28    /// SQL feature not supported.
29    #[error("unsupported feature: {0}")]
30    UnsupportedFeature(String),
31
32    /// Constraint violation (e.g., duplicate primary key, NOT NULL violation).
33    #[error("constraint violation: {0}")]
34    ConstraintViolation(String),
35
36    /// Underlying store error.
37    #[error("store error: {0}")]
38    Store(#[from] StoreError),
39
40    /// JSON serialization/deserialization error.
41    #[error("json error: {0}")]
42    Json(#[from] serde_json::Error),
43}
44
45/// Result type for query operations.
46pub type Result<T> = std::result::Result<T, QueryError>;