Skip to main content

memoir_core/client/
error.rs

1use crate::embedding::EmbeddingError;
2use crate::jobs::JobsError;
3use crate::llm::LlmError;
4use crate::store::StoreError;
5use crate::vector::VectorError;
6
7/// Failure modes for [`crate::client::Client`] construction and operations.
8#[derive(Debug, thiserror::Error)]
9pub enum ClientError {
10    #[error("embedding model failed: {0}")]
11    Embedding(#[from] EmbeddingError),
12
13    #[error("vector index failed: {0}")]
14    Vector(#[from] VectorError),
15
16    #[error("store failed: {0}")]
17    Store(#[from] StoreError),
18
19    #[error("jobs failed: {0}")]
20    Jobs(#[from] JobsError),
21
22    #[error("llm provider failed: {0}")]
23    Llm(#[from] LlmError),
24
25    #[error("migration failed: {0}")]
26    Migration(#[from] crate::migration::MigrationError),
27
28    #[error("database connection failed: {0}")]
29    Database(#[from] sea_orm::DbErr),
30
31    #[error(
32        "metadata uses reserved key '{key}'; reserved keys are owned by memoir-core's payload schema and cannot be set via metadata"
33    )]
34    ReservedMetadataKey { key: String },
35
36    /// NLI classifier initialization failed (epic 0011).
37    #[error("nli classifier failed: {0}")]
38    Nli(String),
39
40    /// Feedback targeted a memory that cannot be corrected (epic 0011).
41    ///
42    /// Feedback corrects a wrong *extraction*, so its target must be a
43    /// semantic row derived from an episodic source. An episodic target
44    /// (correct it via [`crate::client::Client::edit`] instead) or a semantic
45    /// row with no `source_pid` cannot be reprocessed.
46    #[error("memory {pid} is not correctable via feedback: {reason}")]
47    NotCorrectable { pid: String, reason: String },
48
49    /// Knowledge-graph backend failed to connect or initialize (epic 0012).
50    #[cfg(feature = "knowledge-graph")]
51    #[error("knowledge graph failed: {0}")]
52    Graph(#[from] crate::graph::GraphError),
53
54    /// The builder received a `graph_name` but no `falkor` connection (epic 0012).
55    #[cfg(feature = "knowledge-graph")]
56    #[error("a graph_name was configured but no falkor connection was supplied")]
57    GraphNotConfigured,
58}