Skip to main content

nexus_memory_core/
error.rs

1//! Error types for Nexus Memory System
2
3use thiserror::Error;
4
5/// Main error type for Nexus operations
6#[derive(Debug, Error)]
7pub enum NexusError {
8    #[error("Database error: {0}")]
9    Database(String),
10
11    #[error("IO error: {0}")]
12    Io(#[from] std::io::Error),
13
14    #[error("Serialization error: {0}")]
15    Serialization(#[from] serde_json::Error),
16
17    #[error("Namespace not found: {0}")]
18    NamespaceNotFound(String),
19
20    #[error("Memory not found: {0}")]
21    MemoryNotFound(i64),
22
23    #[error("Invalid configuration: {0}")]
24    InvalidConfig(String),
25
26    #[error("Embedding error: {0}")]
27    Embedding(String),
28
29    #[error("Vector search error: {0}")]
30    VectorSearch(String),
31
32    #[error("MCP error: {0}")]
33    Mcp(String),
34
35    #[error("Storage error: {0}")]
36    Storage(String),
37
38    #[error("Not initialized")]
39    NotInitialized,
40
41    #[error("Already initialized")]
42    AlreadyInitialized,
43
44    #[error("Invalid input: {0}")]
45    InvalidInput(String),
46
47    #[error("Internal error: {0}")]
48    Internal(String),
49
50    #[error("LLM error: {0}")]
51    Llm(String),
52
53    #[error("Agent error: {0}")]
54    Agent(String),
55}
56
57/// Result type alias for Nexus operations
58pub type Result<T> = std::result::Result<T, NexusError>;