Skip to main content

popo_cli/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum PopoError {
5    #[error("Network error: {0}")]
6    Network(#[from] reqwest::Error),
7
8    #[error("No report published for {0}")]
9    NotFound(chrono::NaiveDate),
10
11    #[error("Failed to parse report: {0}")]
12    Parse(String),
13
14    #[error("Invalid date '{0}'. Use YYYY-MM-DD (e.g. 2022-03-22)")]
15    InvalidDate(String),
16
17    #[error("Feed error: {0}")]
18    Feed(String),
19
20    #[error(
21        "This feed uses schema version {found}, but this build of popo understands \
22         version {supported}. Upgrade with `cargo install popo-cli --force`."
23    )]
24    UnsupportedSchema { found: u32, supported: u32 },
25
26    #[error("Failed to read local feed at {path}: {source}")]
27    LocalFeed {
28        path: String,
29        #[source]
30        source: std::io::Error,
31    },
32}
33
34pub type Result<T> = std::result::Result<T, PopoError>;