1use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
8pub enum DownloadError {
9 #[error("HTTP error: {0}")]
11 Http(#[from] reqwest::Error),
12
13 #[error("I/O error: {0}")]
15 Io(#[from] std::io::Error),
16
17 #[error("ZIP error: {0}")]
19 Zip(#[from] zip::result::ZipError),
20
21 #[error("unknown service code: {0}")]
23 UnknownService(String),
24
25 #[error("file not found: {url}")]
27 NotFound { url: String },
28
29 #[error("server error {status} for {url}")]
31 ServerError { status: u16, url: String },
32
33 #[error("incomplete download: expected {expected} bytes, got {actual}")]
35 IncompleteDownload { expected: u64, actual: u64 },
36
37 #[error("failed to create cache directory: {path}")]
39 CacheDirectoryError { path: PathBuf },
40
41 #[error("invalid configuration: {0}")]
43 InvalidConfig(String),
44}
45
46pub type Result<T> = std::result::Result<T, DownloadError>;