summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs66
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 @@
1use feed_rs::parser;
2use thiserror::Error;
3use url::Url;
4
5#[derive(Debug, Error)]
6pub 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)]
18pub 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)]
33pub 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)]
48pub 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)]
57pub 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}