1#[derive(Fail, Debug)]
2pub enum APIError {
3 #[fail(display = "Serde issue parsing error {}", _0)]
4 Serde(#[fail(cause)] serde_json::Error),
5 #[fail(display = "Websocket error {}", _0)]
6 Websocket(#[fail(cause)] tokio_tungstenite::tungstenite::Error),
7 #[fail(display = "REST Call error {}", _0)]
8 HTTP(#[fail(cause)] reqwest::Error),
9 #[fail(display = "Other issue {}", _0)]
10 Other(String),
11}
12
13impl APIError {}
14
15impl From<reqwest::Error> for APIError {
16 fn from(err: reqwest::Error) -> Self {
17 APIError::HTTP(err)
18 }
19}
20
21impl From<serde_json::Error> for APIError {
22 fn from(err: serde_json::Error) -> Self {
23 APIError::Serde(err)
24 }
25}
26
27impl From<tokio_tungstenite::tungstenite::Error> for APIError {
28 fn from(err: tokio_tungstenite::tungstenite::Error) -> Self {
29 APIError::Websocket(err)
30 }
31}