1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum ChkpttError {
5 #[error("IO error: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("SQLite error: {0}")]
9 Sqlite(#[from] rusqlite::Error),
10
11 #[error("Bitcode error: {0}")]
12 Bitcode(String),
13
14 #[error("Snapshot not found: {0}")]
15 SnapshotNotFound(String),
16
17 #[error("Lock held by another process")]
18 LockHeld,
19
20 #[error("Guardrail exceeded: {0}")]
21 GuardrailExceeded(String),
22
23 #[error("Store corrupted: {0}")]
24 StoreCorrupted(String),
25
26 #[error("Object not found: {0}")]
27 ObjectNotFound(String),
28
29 #[error("Restore failed: {0}")]
30 RestoreFailed(String),
31
32 #[error("{0}")]
33 Other(String),
34}
35
36pub type Result<T> = std::result::Result<T, ChkpttError>;
37
38impl From<bitcode::Error> for ChkpttError {
39 fn from(e: bitcode::Error) -> Self {
40 ChkpttError::Bitcode(e.to_string())
41 }
42}