Skip to main content

neuxdb/
error.rs

1use thiserror::Error;
2#[derive(Debug, Error)]
3pub enum Error {
4    #[error("I/O error: {0}")]
5    Io(#[from] std::io::Error),
6    #[error("JSON error: {0}")]
7    Json(#[from] serde_json::Error),
8    #[error("Crypto error: {0}")]
9    Crypto(String),
10    #[error("Integrity error: {0}")]
11    Integrity(String),
12    #[error("Table '{0}' not found")]
13    TableNotFound(String),
14    #[error("Table '{0}' already exists")]
15    TableExists(String),
16    #[error("Column '{0}' not found")]
17    ColumnNotFound(String),
18    #[error("Invalid column index {0}")]
19    InvalidColumnIndex(usize),
20    #[error("Database not open")]
21    NotOpen,
22    #[error("Invalid password")]
23    InvalidPassword,
24    #[error("Invalid database format: {0}")]
25    InvalidFormat(String),
26    #[error("Invalid input: {0}")]
27    InvalidInput(String),
28    #[error("Database is locked by another process")]
29    DatabaseLocked,
30    #[error("Version mismatch: expected {expected}, got {actual}")]
31    VersionMismatch { expected: u8, actual: u8 },
32    #[error("Passphrase is too weak: {0}")]
33    WeakPassphrase(String),
34    #[error("Type mismatch: column '{column}' expects {expected} but got {actual}")]
35    TypeMismatch {
36        column: String,
37        expected: String,
38        actual: String,
39    },
40    #[error("CSV error: {0}")]
41    Csv(#[from] csv::Error),
42}
43pub type Result<T> = std::result::Result<T, Error>;