Skip to main content

zeph_memory/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4/// Top-level error type for all `zeph-memory` operations.
5///
6/// Wraps database, vector-store, LLM, and serialization errors into a single type
7/// consumed by callers in `zeph-core`.
8///
9/// # Examples
10///
11/// ```rust
12/// use zeph_memory::MemoryError;
13///
14/// fn demo(e: MemoryError) -> String {
15///     e.to_string()
16/// }
17/// ```
18#[derive(Debug, thiserror::Error)]
19pub enum MemoryError {
20    #[error("database error: {0}")]
21    Sqlx(#[from] zeph_db::SqlxError),
22
23    #[error("database error: {0}")]
24    Db(#[from] zeph_db::DbError),
25
26    #[error("Qdrant error: {0}")]
27    Qdrant(#[from] Box<qdrant_client::QdrantError>),
28
29    #[error("vector store error: {0}")]
30    VectorStore(#[from] crate::vector_store::VectorStoreError),
31
32    #[error("LLM error: {0}")]
33    Llm(#[from] zeph_llm::LlmError),
34
35    #[error("JSON error: {0}")]
36    Json(#[from] serde_json::Error),
37
38    #[error("integer conversion: {0}")]
39    IntConversion(#[from] std::num::TryFromIntError),
40
41    #[error("snapshot error: {0}")]
42    Snapshot(String),
43
44    #[error("I/O error: {0}")]
45    Io(#[from] std::io::Error),
46
47    #[error("graph store error: {0}")]
48    GraphStore(String),
49
50    #[error("invalid input: {0}")]
51    InvalidInput(String),
52
53    /// A mutex or `RwLock` was poisoned by a panicking thread.
54    ///
55    /// This indicates a programming error (a thread panicked while holding the lock).
56    /// The inner string describes which lock was poisoned.
57    #[error("lock poisoned: {0}")]
58    LockPoisoned(String),
59
60    /// Catch-all for errors that do not yet have a specific typed variant.
61    ///
62    /// # Deprecation
63    ///
64    /// Prefer adding a typed variant over using `Other`. This variant exists for
65    /// backward compatibility and will be removed once all callsites are migrated.
66    #[error("{0}")]
67    Other(String),
68
69    #[error("operation timed out: {0}")]
70    Timeout(String),
71
72    /// Returned when inserting a supersede pointer would form a cycle in the chain.
73    #[error("supersede cycle detected at edge id={0}")]
74    SupersedeCycle(i64),
75
76    /// Returned when the supersede chain depth would exceed [`crate::graph::conflict::SUPERSEDE_DEPTH_CAP`].
77    #[error("supersede chain depth cap exceeded at edge id={0}")]
78    SupersedeDepthExceeded(i64),
79
80    /// A promotion-scan or promote error (Feature A, #3305).
81    ///
82    /// Wraps errors from clustering, skill generation, evaluator calls, or disk writes.
83    #[error("promotion scan failed: {0}")]
84    Promotion(String),
85}