1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Top-level error type for recall-echo.
//!
//! Unifies error handling across the crate. The graph subsystem has its own
//! `GraphError` which is wrapped here for seamless propagation.
use crate::graph::error::GraphError;
/// All errors that recall-echo operations can produce.
#[derive(thiserror::Error, Debug)]
pub enum RecallError {
/// I/O errors (file reads, writes, directory operations).
#[error("io: {0}")]
Io(#[from] std::io::Error),
/// JSON serialization/deserialization errors.
#[error("json: {0}")]
Json(#[from] serde_json::Error),
/// TOML serialization errors.
#[error("toml: {0}")]
TomlSerialize(#[from] toml::ser::Error),
/// TOML deserialization errors.
#[error("toml: {0}")]
TomlDeserialize(#[from] toml::de::Error),
/// Configuration errors (missing fields, invalid values).
#[error("config: {0}")]
Config(String),
/// Memory system not initialized or missing required files/directories.
#[error("{0}")]
NotInitialized(String),
/// Graph subsystem errors (wraps GraphError).
#[error("graph: {0}")]
Graph(#[from] GraphError),
/// The graph daemon could not be reached or started. Carries an actionable
/// message — there is no silent fallback to a direct store open.
#[error("graph daemon: {0}")]
Daemon(String),
/// A failure reported by the graph daemon, with its stable error code.
#[error("{message}")]
Remote { code: String, message: String },
/// General errors that don't fit other categories.
#[error("{0}")]
Other(String),
}
impl From<String> for RecallError {
fn from(s: String) -> Self {
RecallError::Other(s)
}
}
impl From<&str> for RecallError {
fn from(s: &str) -> Self {
RecallError::Other(s.to_string())
}
}
/// Convenience alias used across non-graph modules.
pub type Result<T> = std::result::Result<T, RecallError>;