Skip to main content

hibp_bin_fetch/
error.rs

1use std::io;
2use std::path::PathBuf;
3
4use compact_str::CompactString;
5
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    #[error("HTTP request failed for prefix {prefix}: {source}")]
9    HttpRequest {
10        prefix: CompactString,
11        #[source]
12        source: reqwest::Error,
13    },
14
15    #[error("HTTP {status} for prefix {prefix}")]
16    HttpStatus { prefix: CompactString, status: u16 },
17
18    #[error("I/O error: {0}")]
19    Io(#[from] io::Error),
20
21    #[error("File '{path}' exists. Use --force to overwrite or --resume to continue.")]
22    FileExists { path: PathBuf },
23
24    #[error("Cannot use --resume and --force together")]
25    InvalidArgs,
26
27    #[error("invalid configuration: {0}")]
28    InvalidConfig(&'static str),
29
30    #[error("Download failed after {retries} retries for prefix {prefix}")]
31    MaxRetriesExceeded { prefix: CompactString, retries: u32 },
32}