Skip to main content

mentedb_core/
error.rs

1//! Error types for MenteDB.
2
3use thiserror::Error;
4
5use crate::types::MemoryId;
6
7/// Top-level error type for MenteDB operations.
8#[derive(Debug, Error)]
9pub enum MenteError {
10    /// The requested memory was not found.
11    #[error("memory not found: {0}")]
12    MemoryNotFound(MemoryId),
13
14    /// A storage-layer error occurred.
15    #[error("storage error: {0}")]
16    Storage(String),
17
18    /// An index-layer error occurred.
19    #[error("index error: {0}")]
20    Index(String),
21
22    /// A query-layer error occurred.
23    #[error("query error: {0}")]
24    Query(String),
25
26    /// A serialization or deserialization error occurred.
27    #[error("serialization error: {0}")]
28    Serialization(String),
29
30    /// A capacity limit was exceeded.
31    #[error("capacity exceeded: {0}")]
32    CapacityExceeded(String),
33
34    /// The agent does not have permission to access the memory space.
35    #[error("permission denied: agent {agent_id} cannot access space {space_id}")]
36    PermissionDenied {
37        /// The agent that was denied access.
38        agent_id: crate::types::AgentId,
39        /// The space that was inaccessible.
40        space_id: crate::types::SpaceId,
41    },
42
43    /// A resource limit has been exhausted.
44    #[error("resource exhausted: {0}")]
45    ResourceExhausted(String),
46
47    /// An I/O error occurred.
48    #[error(transparent)]
49    Io(#[from] std::io::Error),
50}
51
52/// Convenience result type for MenteDB operations.
53pub type MenteResult<T> = Result<T, MenteError>;