strecken_info/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#[derive(Debug)]
pub enum StreckenInfoError {
    /// A HTTP error occured while requesting
    RequestError(reqwest::Error),
    /// A websocket error occured
    WebsocketError(tokio_tungstenite::tungstenite::Error),
    /// The websocket sent no revision
    WebSocketNoRevisionError,
    JsonError(serde_json::Error),
    /// This error could happen if the server doesn't respond with the right response to a request
    InvalidResponse,
    /// The server sends an error field which is `OK` by default, if it's this error will be thrown
    ResponseError(String),
    /// There are multiple references in the response, this error will be thrown if they are broken
    ReferenceError,
}

impl From<reqwest::Error> for StreckenInfoError {
    fn from(value: reqwest::Error) -> Self {
        Self::RequestError(value)
    }
}

impl From<tokio_tungstenite::tungstenite::Error> for StreckenInfoError {
    fn from(value: tokio_tungstenite::tungstenite::Error) -> Self {
        Self::WebsocketError(value)
    }
}

impl From<serde_json::Error> for StreckenInfoError {
    fn from(value: serde_json::Error) -> Self {
        Self::JsonError(value)
    }
}