1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Mem7Error {
5 #[error("LLM error: {0}")]
6 Llm(String),
7
8 #[error("Embedding error: {0}")]
9 Embedding(String),
10
11 #[error("Vector store error: {0}")]
12 VectorStore(String),
13
14 #[error("History DB error: {0}")]
15 History(String),
16
17 #[error("Configuration error: {0}")]
18 Config(String),
19
20 #[error("Serialization error: {0}")]
21 Serialization(String),
22
23 #[error("HTTP error: {source}")]
24 Http {
25 #[from]
26 source: reqwest::Error,
27 },
28
29 #[error("JSON error: {source}")]
30 Json {
31 #[from]
32 source: serde_json::Error,
33 },
34
35 #[error("SQLite error: {0}")]
36 Sqlite(String),
37
38 #[error("Not found: {0}")]
39 NotFound(String),
40
41 #[error("{0}")]
42 Other(String),
43}
44
45impl From<tokio_rusqlite::Error> for Mem7Error {
46 fn from(e: tokio_rusqlite::Error) -> Self {
47 Mem7Error::Sqlite(e.to_string())
48 }
49}
50
51impl From<rusqlite::Error> for Mem7Error {
52 fn from(e: rusqlite::Error) -> Self {
53 Mem7Error::Sqlite(e.to_string())
54 }
55}
56
57pub type Result<T> = std::result::Result<T, Mem7Error>;