Skip to main content

seshat_storage/
error.rs

1/// Errors originating from the storage layer.
2#[derive(Debug, thiserror::Error)]
3pub enum StorageError {
4    /// Database open or creation failed.
5    #[error("Failed to open database at {path}: {reason}")]
6    OpenError { path: String, reason: String },
7
8    /// A database migration failed.
9    #[error("Migration failed: {0}")]
10    MigrationError(String),
11
12    /// A query returned unexpected results.
13    #[error("Query error: {0}")]
14    QueryError(String),
15
16    /// Serialization/deserialization of IR data failed.
17    #[error("IR serialization error: {0}")]
18    SerializationError(String),
19
20    /// Cached IR has a stale schema version and must be re-parsed.
21    #[error("Stale IR: cached version {cached} != current version {current}")]
22    StaleIR { cached: u8, current: u8 },
23
24    /// The requested entity was not found.
25    #[error("{entity} not found: {id}")]
26    NotFound { entity: &'static str, id: String },
27
28    /// SQLite error.
29    #[error("SQLite error: {0}")]
30    Sqlite(#[from] rusqlite::Error),
31
32    /// IO error.
33    #[error("IO error: {0}")]
34    Io(#[from] std::io::Error),
35}