diff options
author | Akshay <[email protected]> | 2023-05-07 12:41:48 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2023-05-07 12:41:48 +0100 |
commit | f13e8be9f32c5ca7f70dc809e3d43144f8e31396 (patch) | |
tree | b0cf92d61a3ae3780cea633697e6cf5104132984 /src/error.rs | |
parent | 83c91eeeab4080d4dccd87607cf887e0133aa625 (diff) |
progress
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..8a2059e --- /dev/null +++ b/src/error.rs | |||
@@ -0,0 +1,66 @@ | |||
1 | use feed_rs::parser; | ||
2 | use thiserror::Error; | ||
3 | use url::Url; | ||
4 | |||
5 | #[derive(Debug, Error)] | ||
6 | pub enum Error { | ||
7 | #[error("error pulling feed `{0}`: {1}")] | ||
8 | Pull(Url, PullError), | ||
9 | |||
10 | #[error("error parsing entry: {0}")] | ||
11 | Entry(#[from] EntryError), | ||
12 | |||
13 | #[error("error adding field: {0}")] | ||
14 | Add(#[from] AddError), | ||
15 | } | ||
16 | |||
17 | #[derive(Debug, Error)] | ||
18 | pub enum PullError { | ||
19 | #[error("failed to make request")] | ||
20 | Request(#[from] reqwest::Error), | ||
21 | |||
22 | #[error("invalid rss feed: {0}")] | ||
23 | Parse(#[from] parser::ParseFeedError), | ||
24 | |||
25 | #[error("failed to pull feed title")] | ||
26 | TitleUpdate, | ||
27 | |||
28 | #[error("failed to pull feed link")] | ||
29 | LinkUpdate, | ||
30 | } | ||
31 | |||
32 | #[derive(Debug, Error)] | ||
33 | pub enum EntryError { | ||
34 | #[error("missing title")] | ||
35 | MissingTitle, | ||
36 | |||
37 | #[error("missing link")] | ||
38 | MissingLink, | ||
39 | |||
40 | #[error("invalid link")] | ||
41 | InvalidLink, | ||
42 | |||
43 | #[error("missing publish-date")] | ||
44 | MissingPubDate, | ||
45 | } | ||
46 | |||
47 | #[derive(Debug, Error)] | ||
48 | pub enum AddError { | ||
49 | #[error("invalid url: {0}")] | ||
50 | InvalidUrl(String), | ||
51 | |||
52 | #[error("feed is already present")] | ||
53 | DuplicateLink, | ||
54 | } | ||
55 | |||
56 | #[derive(Debug, Error)] | ||
57 | pub enum IOError { | ||
58 | #[error("unable to create or find store path")] | ||
59 | MissingStorePath, | ||
60 | |||
61 | #[error("file error:")] | ||
62 | FileIO(#[from] std::io::Error), | ||
63 | |||
64 | #[error("yaml ser/de error")] | ||
65 | Serde(#[from] serde_yaml::Error), | ||
66 | } | ||