Skip to main content

memoir_core/store/
error.rs

1use crate::memory::{MemoryKind, ScopeError};
2
3/// Failure modes for [`crate::store::MemoryStore`] implementations.
4#[derive(Debug, thiserror::Error)]
5pub enum StoreError {
6    #[error("memory not found: {0}")]
7    NotFound(String),
8
9    #[error("invalid scope: {0}")]
10    InvalidScope(String),
11
12    /// `edit` was called on a memory whose kind does not support in-place
13    /// edits. Today this is every non-Episodic kind; Semantic rows require
14    /// the Override-conversion path that epic 0011 introduces, and editing
15    /// them via this method would silently break the `source_pid`
16    /// provenance contract.
17    #[error("edit not supported for memory {pid} with kind {kind:?}")]
18    UnsupportedEdit { pid: String, kind: MemoryKind },
19
20    #[error("database error: {0}")]
21    Database(#[from] sea_orm::DbErr),
22
23    #[error("cache invariant violated: {0}")]
24    CacheInvariant(String),
25}
26
27impl From<ScopeError> for StoreError {
28    fn from(err: ScopeError) -> Self {
29        Self::InvalidScope(err.to_string())
30    }
31}