1#[derive(Debug, thiserror::Error)]
6pub enum MemoryError {
7 #[error("Database error: {0}")]
9 Database(#[from] rusqlite::Error),
10
11 #[error("Embedding request failed: {0}")]
13 EmbeddingRequest(#[from] reqwest::Error),
14
15 #[error("Embedding provider returned {actual} dimensions, expected {expected}")]
17 DimensionMismatch { expected: usize, actual: usize },
18
19 #[error("Invalid embedding data: expected {expected_bytes} bytes, got {actual_bytes}")]
21 InvalidEmbedding {
22 expected_bytes: usize,
23 actual_bytes: usize,
24 },
25
26 #[error("Embedding model mismatch: database has '{stored}', config specifies '{configured}'")]
28 ModelMismatch { stored: String, configured: String },
29
30 #[error("Session not found: {0}")]
32 SessionNotFound(String),
33
34 #[error("Fact not found: {0}")]
36 FactNotFound(String),
37
38 #[error("Document not found: {0}")]
40 DocumentNotFound(String),
41
42 #[error("Embedding provider unavailable: {0}")]
44 EmbedderUnavailable(String),
45
46 #[error("Migration failed at version {version}: {reason}")]
48 MigrationFailed { version: u32, reason: String },
49
50 #[error("HNSW index error: {0}")]
52 HnswError(String),
53
54 #[error("Invalid HNSW key format: {0}")]
56 InvalidKey(String),
57
58 #[error("Quantization error: {0}")]
60 QuantizationError(String),
61
62 #[error("Storage path error: {0}")]
64 StorageError(String),
65
66 #[error("Index integrity check failed: {in_sqlite_not_hnsw} items in SQLite but not HNSW, {in_hnsw_not_sqlite} items in HNSW but not SQLite")]
68 IntegrityError {
69 in_sqlite_not_hnsw: usize,
70 in_hnsw_not_sqlite: usize,
71 },
72
73 #[error("{0}")]
75 Other(String),
76}