Skip to main content

sntl_schema/
error.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, Error)]
7pub enum Error {
8    #[error("IO error on {path}: {source}")]
9    Io {
10        path: PathBuf,
11        #[source]
12        source: std::io::Error,
13    },
14
15    #[error("TOML parse error in {path}: {source}")]
16    TomlParse {
17        path: PathBuf,
18        #[source]
19        source: toml::de::Error,
20    },
21
22    #[error("JSON parse error in {path}: {source}")]
23    JsonParse {
24        path: PathBuf,
25        #[source]
26        source: serde_json::Error,
27    },
28
29    #[error("SQL parse error: {0}")]
30    SqlParse(String),
31
32    #[error(
33        "cache format version {found} is newer than supported {supported}; upgrade sntl-macros"
34    )]
35    CacheVersionTooNew { found: u32, supported: u32 },
36
37    #[error("cache miss: query not found at {path}")]
38    CacheMiss { path: PathBuf },
39
40    #[error("schema snapshot missing table `{table}`")]
41    UnknownTable { table: String },
42
43    #[error("schema snapshot missing column `{table}.{column}`")]
44    UnknownColumn { table: String, column: String },
45
46    #[error("column ambiguity: `{column}` could refer to multiple tables: {candidates:?}")]
47    AmbiguousColumn {
48        column: String,
49        candidates: Vec<String>,
50    },
51
52    #[error("configuration error: {0}")]
53    Config(String),
54
55    #[error("introspection error: {0}")]
56    Introspect(String),
57}