1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("Initialization failed: {0}")]
10 Initialization(String),
11
12 #[error("Configuration error: {0}")]
14 Config(String),
15
16 #[error("HTTP request failed: {0}")]
18 HttpRequest(String),
19
20 #[error("Parse failed: {0}")]
22 Parse(String),
23
24 #[error("Cache operation failed: {0}")]
26 Cache(String),
27
28 #[error("Authentication failed: {0}")]
30 Auth(String),
31
32 #[error("MCP protocol error: {0}")]
34 Mcp(String),
35
36 #[error("IO error: {0}")]
38 Io(#[from] std::io::Error),
39
40 #[error("JSON error: {0}")]
42 Json(#[from] serde_json::Error),
43
44 #[error("URL parse error: {0}")]
46 Url(#[from] url::ParseError),
47
48 #[error("HTTP client error: {0}")]
50 Reqwest(#[from] reqwest::Error),
51
52 #[error("Unknown error: {0}")]
54 Other(String),
55}
56
57pub type Result<T> = std::result::Result<T, Error>;
59
60impl From<Box<dyn std::error::Error + Send + Sync>> for Error {
61 fn from(err: Box<dyn std::error::Error + Send + Sync>) -> Self {
62 Error::Other(err.to_string())
63 }
64}
65
66impl From<anyhow::Error> for Error {
67 fn from(err: anyhow::Error) -> Self {
68 Error::Other(err.to_string())
69 }
70}