Skip to main content

uls_download/
error.rs

1//! Error types for download operations.
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors that can occur during download operations.
7#[derive(Error, Debug)]
8pub enum DownloadError {
9    /// HTTP request failed.
10    #[error("HTTP error: {0}")]
11    Http(#[from] reqwest::Error),
12
13    /// I/O error during file operations.
14    #[error("I/O error: {0}")]
15    Io(#[from] std::io::Error),
16
17    /// ZIP extraction error.
18    #[error("ZIP error: {0}")]
19    Zip(#[from] zip::result::ZipError),
20
21    /// Unknown service code.
22    #[error("unknown service code: {0}")]
23    UnknownService(String),
24
25    /// File not found on FCC server.
26    #[error("file not found: {url}")]
27    NotFound { url: String },
28
29    /// Server returned an error status.
30    #[error("server error {status} for {url}")]
31    ServerError { status: u16, url: String },
32
33    /// Download was interrupted or incomplete.
34    #[error("incomplete download: expected {expected} bytes, got {actual}")]
35    IncompleteDownload { expected: u64, actual: u64 },
36
37    /// Cache directory could not be created.
38    #[error("failed to create cache directory: {path}")]
39    CacheDirectoryError { path: PathBuf },
40
41    /// Invalid configuration.
42    #[error("invalid configuration: {0}")]
43    InvalidConfig(String),
44}
45
46/// Result type for download operations.
47pub type Result<T> = std::result::Result<T, DownloadError>;