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
use reqwest;
use serde_json;

#[derive(Debug)]
pub enum OpenNotificationError {
    /// Something went wrong while fetching the data.
    Network(reqwest::Error),

    /// Unexpected message structure.
    Parsing(serde_json::Error),

    /// Unexpected or inconsistent information is detected.
    Data(String),
}

impl From<serde_json::Error> for OpenNotificationError {
    fn from(e: serde_json::Error) -> OpenNotificationError {
        OpenNotificationError::Parsing(e)
    }
}

impl From<reqwest::Error> for OpenNotificationError {
    fn from(e: reqwest::Error) -> OpenNotificationError {
        OpenNotificationError::Network(e)
    }
}