Skip to main content

webserver_base/feed/
error.rs

1//! Why a feed could not be produced.
2
3/// Why a feed could not be produced.
4///
5/// Every variant except the serialization ones is a boot failure: the deploy
6/// never cuts over and the previous container keeps serving, which is the same
7/// signal as a broken feed without the outage.
8#[derive(Debug, thiserror::Error)]
9pub enum FeedError {
10    /// An entry is missing something every reader renders.
11    #[error("feed entry `{path}` has an empty {field}; readers render it as a blank row")]
12    IncompleteEntry { path: String, field: &'static str },
13
14    /// An entry's path is not site-relative, so it cannot become a stable id.
15    #[error(
16        "feed entry path `{path}` is not rooted; use a site-relative path such as `/blog/a-post`"
17    )]
18    UnrootedPath { path: String },
19
20    /// Content carries a `srcset`, whose comma-separated URL+descriptor grammar
21    /// this library deliberately does not rewrite.
22    #[error(
23        "feed entry `{path}` uses `srcset`, which is not rewritten; use a single `src` so the \
24         feed cannot ship half-absolute image URLs"
25    )]
26    SrcsetUnsupported { path: String },
27
28    /// The feed advertises a page the site does not serve.
29    #[error(
30        "the feed's page `{page_url}` is not a declared page; its `rel=\"alternate\"` would 404"
31    )]
32    PageNotDeclared { page_url: String },
33
34    /// A declared entry image is absent from the asset manifest.
35    #[error("feed entry `{path}` names image `{image}`, which is not in the asset manifest")]
36    UnresolvedImage { path: String, image: String },
37
38    /// The XML could not be written.
39    #[error("failed to serialize the {format} feed")]
40    Write {
41        format: &'static str,
42        #[source]
43        source: std::io::Error,
44    },
45
46    /// Serialized XML was not valid UTF-8, which cannot happen for input this
47    /// module produces.
48    #[error("the serialized {format} feed was not valid UTF-8")]
49    Encoding { format: &'static str },
50
51    /// JSON Feed could not be serialized.
52    #[error("failed to serialize the JSON feed")]
53    Json {
54        #[source]
55        source: serde_json::Error,
56    },
57}