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
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("RSS parsing error")]
Rss(#[from] rss::Error),
#[error("HTML parsing error")]
Html(#[from] HtmlError),
#[error("JSON parsing error")]
Json(#[from] JsonError),
}
#[derive(thiserror::Error, Debug)]
pub enum HtmlError {
#[error("URL not found")]
UrlNotFound,
#[error("Invalid URL")]
InvalidUrl(#[from] url::ParseError),
#[error("ID not found")]
IdNotFound,
#[error("Image not found but it's not optional")]
ImageNotFound,
#[error("Invalid time format")]
InvalidTimeFormat(#[from] chrono::ParseError),
}
#[derive(thiserror::Error, Debug)]
pub enum JsonError {
#[error("Invalid JSON")]
JsonParseInvalid(#[from] serde_json::error::Error),
#[error("JSON key {0} not found")]
JsonParseKeyNotFound(String),
#[error("JSON key {key} wrong type: expected {expected_type}, found {found_type}")]
JsonParseKeyWrongType {
key: String,
expected_type: &'static str,
found_type: String,
},
#[error("ID not found")]
InvalidUrl(#[from] url::ParseError),
}