1use thiserror::Error;
4use uuid::Uuid;
5
6pub type FoldResult<T> = std::result::Result<T, FoldError>;
8
9#[derive(Error, Debug)]
11pub enum FoldError {
12 #[error("Entry {0} not found")]
14 EntryNotFound(Uuid),
15
16 #[error("Invalid entry type: expected {expected}, got {actual}")]
18 InvalidEntryType {
19 expected: String,
21 actual: String,
23 },
24
25 #[error("Context error: {0}")]
27 Context(String),
28
29 #[error("Serialization error: {0}")]
31 Serialization(#[from] serde_json::Error),
32
33 #[error("Storage error: {0}")]
35 Storage(String),
36
37 #[error("Internal lock poisoned: {0}")]
39 LockPoisoned(String),
40
41 #[error("invalid input: {0}")]
43 InvalidInput(String),
44
45 #[error("budget exhausted: needed {needed}, have {budget}")]
47 BudgetExhausted {
48 needed: usize,
50 budget: usize,
52 },
53
54 #[error("anchor not found: {0}")]
56 AnchorNotFound(String),
57
58 #[error("required component not configured: {0}")]
60 ComponentMissing(String),
61
62 #[error("checkpoint integrity mismatch for '{id}': stored {stored}, computed {computed}")]
64 IntegrityMismatch {
65 id: String,
67 stored: String,
69 computed: String,
71 },
72
73 #[error("checkpoint not found: {0}")]
75 CheckpointNotFound(String),
76}
77
78#[cfg(test)]
79#[path = "error_tests.rs"]
80mod tests;