1#[derive(Debug, thiserror::Error)]
19#[non_exhaustive]
20pub enum MemoryError {
21 #[error("sqlx error: {0}")]
22 Sqlx(#[from] zeph_db::SqlxError),
23
24 #[error("db error: {0}")]
25 Db(#[from] zeph_db::DbError),
26
27 #[error("Qdrant error: {0}")]
28 Qdrant(#[from] Box<qdrant_client::QdrantError>),
29
30 #[error("vector store error: {0}")]
31 VectorStore(#[from] crate::vector_store::VectorStoreError),
32
33 #[error("LLM error: {0}")]
34 Llm(#[from] zeph_llm::LlmError),
35
36 #[error("JSON error: {0}")]
37 Json(#[from] serde_json::Error),
38
39 #[error("integer conversion: {0}")]
40 IntConversion(#[from] std::num::TryFromIntError),
41
42 #[error("snapshot error: {0}")]
43 Snapshot(String),
44
45 #[error("I/O error: {0}")]
46 Io(#[from] std::io::Error),
47
48 #[error("graph store error: {0}")]
49 GraphStore(String),
50
51 #[error("invalid input: {0}")]
52 InvalidInput(String),
53
54 #[error("lock poisoned: {0}")]
59 LockPoisoned(String),
60
61 #[error("{0}")]
68 Other(String),
69
70 #[error("operation timed out: {0}")]
71 Timeout(String),
72
73 #[error("supersede cycle detected at edge id={0}")]
75 SupersedeCycle(i64),
76
77 #[error("supersede chain depth cap exceeded at edge id={0}")]
79 SupersedeDepthExceeded(i64),
80
81 #[error("promotion scan failed: {0}")]
85 Promotion(String),
86}
87
88#[cfg(test)]
89mod tests {
90 use super::MemoryError;
91
92 #[test]
93 fn sqlx_variant_display() {
94 let inner = zeph_db::SqlxError::RowNotFound;
95 let err = MemoryError::Sqlx(inner);
96 assert!(
97 err.to_string().starts_with("sqlx error:"),
98 "unexpected display: {err}"
99 );
100 }
101
102 #[test]
103 fn db_variant_display() {
104 let inner = zeph_db::DbError::Io(std::io::Error::new(std::io::ErrorKind::NotFound, "test"));
105 let err = MemoryError::Db(inner);
106 assert!(
107 err.to_string().starts_with("db error:"),
108 "unexpected display: {err}"
109 );
110 }
111}