use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("storage error: {0}")]
Storage(String),
#[error("vector index error: {0}")]
VectorIndex(String),
#[error("embedder error: {0}")]
Embedder(String),
#[error("embedder protocol violation: {0}")]
EmbedderProtocol(&'static str),
#[error("LLM client error: {0}")]
Llm(String),
#[error("steward error: {0}")]
Steward(String),
#[error("invalid input: {0}")]
InvalidInput(String),
#[error("not found: {0}")]
NotFound(String),
#[error("conflict: {0}")]
Conflict(String),
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("serialization error: {0}")]
Serde(#[from] serde_json::Error),
#[error("uuid error: {0}")]
Uuid(#[from] uuid::Error),
#[error("other: {0}")]
Other(String),
}
impl Error {
pub fn storage(msg: impl Into<String>) -> Self {
Self::Storage(msg.into())
}
pub fn vector_index(msg: impl Into<String>) -> Self {
Self::VectorIndex(msg.into())
}
pub fn embedder(msg: impl Into<String>) -> Self {
Self::Embedder(msg.into())
}
pub fn llm(msg: impl Into<String>) -> Self {
Self::Llm(msg.into())
}
pub fn steward(msg: impl Into<String>) -> Self {
Self::Steward(msg.into())
}
pub fn invalid_input(msg: impl Into<String>) -> Self {
Self::InvalidInput(msg.into())
}
pub fn not_found(msg: impl Into<String>) -> Self {
Self::NotFound(msg.into())
}
pub fn conflict(msg: impl Into<String>) -> Self {
Self::Conflict(msg.into())
}
}