blob: 6b9f5d519d660dd9b72b1703af78a2b334485b14 (
plain)
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
35
36
37
38
39
40
41
|
use reqwest::Error as ReqwestError;
use std::convert::From;
#[derive(Debug)]
enum Kind {
Reqwest(ReqwestError),
ClientError(String),
}
#[derive(Debug)]
pub struct Error {
inner: Kind
}
impl From<reqwest::Error> for Error {
fn from(err: ReqwestError) -> Error {
Error {
inner: Kind::Reqwest(err)
}
}
}
impl From<()> for Error {
fn from(err: ()) -> Error {
Error {
inner: Kind::ClientError("Internal error".to_owned())
}
}
}
impl From<futures::Canceled> for Error {
fn from(_err: futures::Canceled) -> Error {
Error {
inner: Kind::ClientError("Oneshot channel unexpectedly closed".to_owned())
}
}
}
|