1use {
2 failure::Fail,
3 std::{fmt, io::Error},
4 tokio::sync::broadcast::error::RecvError,
5};
6
7#[derive(Debug)]
8pub struct RelayError {
9 pub value: PushClientErrorValue,
10}
11
12impl fmt::Display for RelayError {
13 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14 fmt::Display::fmt(&self.value, f)
15 }
16}
17
18#[derive(Debug, Fail)]
19pub enum PushClientErrorValue {
20 #[fail(display = "receive error")]
21 ReceiveError(RecvError),
22
23 #[fail(display = "send error")]
24 SendError,
25 #[fail(display = "io error")]
26 IOError(Error),
27}
28
29impl From<Error> for RelayError {
30 fn from(error: Error) -> Self {
31 RelayError {
32 value: PushClientErrorValue::IOError(error),
33 }
34 }
35}
36
37impl From<RecvError> for RelayError {
38 fn from(error: RecvError) -> Self {
39 RelayError {
40 value: PushClientErrorValue::ReceiveError(error),
41 }
42 }
43}