Skip to main content

knowdit_kg/
error.rs

1use color_eyre::eyre::eyre;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, KgError>;
5
6#[derive(Debug, Error)]
7pub enum KgError {
8    #[error("database error: {0}")]
9    Db(#[from] sea_orm::DbErr),
10
11    #[error("LLM error: {0}")]
12    Llm(#[from] llmy::LLMYError),
13
14    #[error("IO error: {0}")]
15    Io(#[from] std::io::Error),
16
17    #[error("JSON parse error: {0}")]
18    Json(#[from] serde_json::Error),
19
20    #[error("{0}")]
21    Other(#[from] color_eyre::Report),
22}
23
24impl KgError {
25    pub fn other(msg: impl Into<String>) -> Self {
26        Self::Other(eyre!("error: {}", msg.into()))
27    }
28}