Skip to main content

lean_ctx/core/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum LeanCtxError {
5    #[error("IO error: {0}")]
6    Io(#[from] std::io::Error),
7
8    #[error("config error: {0}")]
9    Config(String),
10
11    #[error("parse error: {0}")]
12    Parse(String),
13
14    #[error("tool execution failed: {0}")]
15    ToolExecution(String),
16
17    #[error("network error: {0}")]
18    Network(String),
19
20    #[error("{0}")]
21    Other(String),
22}
23
24impl From<toml::de::Error> for LeanCtxError {
25    fn from(e: toml::de::Error) -> Self {
26        LeanCtxError::Config(e.to_string())
27    }
28}
29
30impl From<serde_json::Error> for LeanCtxError {
31    fn from(e: serde_json::Error) -> Self {
32        LeanCtxError::Parse(e.to_string())
33    }
34}
35
36pub type Result<T> = std::result::Result<T, LeanCtxError>;