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
use hyper;
use hyper_tls;
use tokio_tungstenite::tungstenite;

quick_error! {
    #[derive(Debug)]
    /// Error type for noob functions
    pub enum Error {
        /// Failed to authenticate with the API
        AuthenticationFailed {}
        /// Some other error
        Other(e: String) {}
    }
}

impl From<hyper::Error> for Error {
    fn from(e: hyper::Error) -> Self {
        Error::Other(format!("HTTP Failure: {:?}", e))
    }
}

impl From<hyper_tls::Error> for Error {
    fn from(e: hyper_tls::Error) -> Self {
        Error::Other(format!("HTTPS Failure: {:?}", e))
    }
}

impl From<tungstenite::Error> for Error {
    fn from(e: tungstenite::Error) -> Self {
        Error::Other(format!("WebSocket Failure: {:?}", e))
    }
}