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
use thiserror::Error;
use tor_rtcompat::TimeoutError;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("possible compression bomb")]
CompressionBomb,
#[error("directory timed out")]
DirTimeout,
#[error("truncated HTTP headers")]
TruncatedHeaders,
#[error("unexpected HTTP status {0:?}")]
HttpStatus(Option<u16>),
#[error("response too long; gave up after {0} bytes")]
ResponseTooLong(usize),
#[error("Couldn't decode data as UTF-8.")]
Utf8Encoding(#[from] std::string::FromUtf8Error),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("Couldn't parse HTTP headers")]
HttparseError(#[from] httparse::Error),
#[error("Couldn't create HTTP request")]
HttpError(#[from] http::Error),
#[error("Unrecognized content encoding: {0:?}")]
ContentEncoding(String),
}
impl From<TimeoutError> for Error {
fn from(_: TimeoutError) -> Self {
Error::DirTimeout
}
}
impl Error {
pub fn should_retire_circ(&self) -> bool {
true
}
}