1use thiserror::Error;
4
5pub type XResult<T> = Result<T, XError>;
7
8#[derive(Error, Debug)]
10pub enum XError {
11 #[error("HTTP request failed: {0}")]
13 Http(#[from] reqwest::Error),
14
15 #[error("JSON error: {0}")]
17 Json(#[from] serde_json::Error),
18
19 #[error("IO error: {0}")]
21 Io(#[from] std::io::Error),
22
23 #[error("Server initialization error: {0}")]
25 ServerInit(String),
26
27 #[error("Join error: {0}")]
29 Join(#[from] tokio::task::JoinError),
30
31 #[error("Authentication error: {0}")]
33 Auth(String),
34
35 #[error("X API error: {status} - {message}")]
37 Api { status: u16, message: String },
38
39 #[error("Configuration error: {0}")]
41 Config(String),
42
43 #[error("Error: {0}")]
45 Generic(String),
46}
47
48impl From<anyhow::Error> for XError {
49 fn from(err: anyhow::Error) -> Self {
50 XError::Generic(err.to_string())
51 }
52}
53
54impl<T> From<rmcp::service::ServerInitializeError<T>> for XError
55where
56 T: std::fmt::Display,
57{
58 fn from(err: rmcp::service::ServerInitializeError<T>) -> Self {
59 XError::ServerInit(err.to_string())
60 }
61}