Skip to main content

memory_core/
error.rs

1#[derive(Debug, thiserror::Error)]
2pub enum Error {
3    #[error("database error: {0}")]
4    Database(#[from] rusqlite::Error),
5
6    #[error("memory not found: {0}")]
7    NotFound(i64),
8
9    #[error("empty value: memory must contain something")]
10    EmptyValue,
11
12    #[error("empty key: key is required")]
13    EmptyKey,
14
15    #[error("key too long: {0} chars (max {1})")]
16    KeyTooLong(usize, usize),
17
18    #[error("too many tags: {0} (max {1})")]
19    TooManyTags(usize, usize),
20
21    #[error("tag too long: {0} chars (max {1})")]
22    TagTooLong(usize, usize),
23
24    #[error("invalid scope: {0}")]
25    InvalidScope(String),
26
27    #[error("invalid source type: {0}")]
28    InvalidSourceType(String),
29
30    #[error("invalid input: {0}")]
31    InvalidInput(String),
32
33    #[error("schema version {found} is newer than supported version {supported}")]
34    SchemaVersionTooNew { found: i64, supported: i64 },
35
36    #[error("schema migration failed: {0}")]
37    Migration(String),
38
39    #[error("serialization error: {0}")]
40    Serialization(#[from] serde_json::Error),
41
42    #[error("session not found: {0}")]
43    SessionNotFound(String),
44
45    #[error("session already ended: {0}")]
46    SessionAlreadyEnded(String),
47
48    #[error("encryption error: {0}")]
49    Encryption(String),
50}
51
52pub type Result<T> = std::result::Result<T, Error>;