1use thiserror::Error as ThisError;
2
3#[derive(Debug, ThisError)]
6pub enum Error {
7 #[error("{body}")]
8 Http { status: u16, body: String },
9 #[error("{0}")]
10 Message(String),
11 #[error(transparent)]
12 Request(#[from] reqwest::Error),
13 #[error(transparent)]
14 Json(#[from] serde_json::Error),
15 #[error(transparent)]
16 WebSocket(#[from] Box<tokio_tungstenite::tungstenite::Error>),
17}
18
19impl From<tokio_tungstenite::tungstenite::Error> for Error {
20 fn from(error: tokio_tungstenite::tungstenite::Error) -> Self {
21 Error::WebSocket(Box::new(error))
22 }
23}
24
25pub type Result<T> = std::result::Result<T, Error>;