1#[derive(Debug)]
2pub enum ServerError {
3 Hyper(hyper::Error),
4 Noise(tokio_noise::NoiseError),
5 HandlerTimeout,
6}
7
8impl From<hyper::Error> for ServerError {
9 fn from(e: hyper::Error) -> Self {
10 ServerError::Hyper(e)
11 }
12}
13impl From<tokio_noise::NoiseError> for ServerError {
14 fn from(e: tokio_noise::NoiseError) -> Self {
15 ServerError::Noise(e)
16 }
17}
18
19impl std::fmt::Display for ServerError {
20 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
21 use ServerError::*;
22 write!(
23 f,
24 "noise HTTP server error: {}",
25 match self {
26 Hyper(e) => format!("hyper error: {e}"),
27 Noise(e) => format!("noise error: {e}"),
28 HandlerTimeout => "timed out handling noise HTTP request".to_string(),
29 }
30 )
31 }
32}
33
34impl std::error::Error for ServerError {}
35
36#[derive(Debug)]
37pub enum ClientError {
38 Hyper(hyper::Error),
39 Noise(tokio_noise::NoiseError),
40 RequestTimeout,
41}
42
43impl From<hyper::Error> for ClientError {
44 fn from(e: hyper::Error) -> Self {
45 Self::Hyper(e)
46 }
47}
48impl From<tokio_noise::NoiseError> for ClientError {
49 fn from(e: tokio_noise::NoiseError) -> Self {
50 Self::Noise(e)
51 }
52}
53
54impl std::fmt::Display for ClientError {
55 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
56 use ClientError::*;
57 write!(
58 f,
59 "noise HTTP client error: {}",
60 match self {
61 Hyper(e) => format!("hyper error: {e}"),
62 Noise(e) => format!("noise error: {e}"),
63 RequestTimeout => "timed out waiting for noise HTTP response".to_string(),
64 }
65 )
66 }
67}
68
69impl std::error::Error for ClientError {}