blob: 88f271356e1d4fe831e51cef34897e481985f67e (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
use reqwest::Error as ReqwestError;
use futures::future::SharedError;
use std::convert::From;
/*TODO: How should condition errors be handled?
* Ultimately the future must resolve so if the condition
* errs than all it's waiters must err.
*/
#[derive(Clone, Debug)]
pub struct ConditionError{}
impl From<SharedError<ConditionError>> for ConditionError {
fn from(other: SharedError<ConditionError>) -> Self {
ConditionError{}
}
}
#[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())
}
}
}
use std::sync::mpsc::SendError;
impl<T> From<SendError<T>> for Error {
fn from(_err: SendError<T>) -> Error {
Error {
inner: Kind::ClientError("Channel unexpectedly closed".to_owned())
}
}
}
impl From<ConditionError> for Error {
fn from(_err: ConditionError) -> Error {
Error {
inner: Kind::ClientError("Oneshot channel unexpectedly closed".to_owned())
}
}
}
|