use thiserror::Error;
#[derive(Error, Debug)]
pub enum MemoryError {
#[error("memory with id {0} not found")]
NotFound(String),
#[error("embedding dimension mismatch: expected {expected}, got {actual}")]
DimensionMismatch { expected: usize, actual: usize },
#[error("embedding error: {0}")]
Embedding(#[from] EmbeddingError),
#[error("vector store error: {0}")]
VectorStore(#[from] VectorStoreError),
#[error("LLM error: {0}")]
LLM(#[from] LLMError),
#[error("configuration error: {0}")]
Config(String),
#[error("serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("invalid input: {0}")]
InvalidInput(String),
#[error("history database error: {0}")]
History(String),
#[error("reranking error: {0}")]
Reranker(String),
}
#[derive(Error, Debug)]
pub enum EmbeddingError {
#[error("API error: {0}")]
Api(String),
#[error("network error: {0}")]
Network(String),
#[error("rate limit exceeded")]
RateLimited,
#[error("invalid response: {0}")]
InvalidResponse(String),
#[error("embedding provider not configured")]
NotConfigured,
}
#[derive(Error, Debug)]
pub enum VectorStoreError {
#[error("connection error: {0}")]
Connection(String),
#[error("record not found: {0}")]
NotFound(String),
#[error("insert error: {0}")]
Insert(String),
#[error("search error: {0}")]
Search(String),
#[error("delete error: {0}")]
Delete(String),
#[error("update error: {0}")]
Update(String),
#[error("collection error: {0}")]
Collection(String),
#[error("vector store not configured")]
NotConfigured,
}
#[derive(Error, Debug)]
pub enum LLMError {
#[error("API error: {0}")]
Api(String),
#[error("network error: {0}")]
Network(String),
#[error("rate limit exceeded")]
RateLimited,
#[error("invalid response: {0}")]
InvalidResponse(String),
#[error("JSON parsing error: {0}")]
JsonParse(String),
#[error("LLM provider not configured")]
NotConfigured,
}
pub type Result<T> = std::result::Result<T, MemoryError>;