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
76
77
78
79
use std::{string, io};
use std::error::Error;
use std::fs;
mod notify;
mod cookie;
mod body;
pub use self::cookie::CookieIter;
pub use notify::{Notifier, Noop};
pub use body::{*};
#[derive(Debug, derive_more::Display)]
pub enum BodyReadError {
#[display(fmt = "Read limit is reached. Aborted reading.")]
Overflow(bytes::Bytes),
#[display(fmt = "Unable to decode content into UTF-8")]
EncodingError,
#[display(fmt = "Failed to extract JSON. Error: {}", "_0")]
JsonError(serde_json::error::Error),
#[cfg(feature = "compu")]
#[display(fmt = "Failed to decompress content. Error: {:?}", "_0")]
CompuError(compu::decoder::DecoderResult),
#[display(fmt = "Failed to decompress content as it is not complete")]
IncompleteDecompression,
#[display(fmt = "Error file writing response into file. Error: {}", "_1")]
FileError(fs::File, io::Error),
#[display(fmt = "IO Error while reading: {}", "_0")]
ReadError(io::Error),
#[display(fmt = "Failed to read due to HTTP error: {}", "_0")]
Hyper(hyper::Error),
}
impl From<serde_json::error::Error> for BodyReadError {
#[inline]
fn from(error: serde_json::error::Error) -> Self {
BodyReadError::JsonError(error)
}
}
impl From<string::FromUtf8Error> for BodyReadError {
#[inline]
fn from(_: string::FromUtf8Error) -> Self {
BodyReadError::EncodingError
}
}
impl From<io::Error> for BodyReadError {
#[inline]
fn from(error: io::Error) -> Self {
BodyReadError::ReadError(error)
}
}
impl From<hyper::Error> for BodyReadError {
#[inline]
fn from(err: hyper::Error) -> Self {
BodyReadError::Hyper(err)
}
}
impl Error for BodyReadError {}