cobble_core/error/
download_error.rs

1/// Result with [`DownloadError`](DownloadError) as the error type.
2pub type DownloadResult<T> = Result<T, DownloadError>;
3
4/// An error that occurs during downloading of resources.
5#[derive(Debug, thiserror::Error)]
6pub enum DownloadError {
7    /// Error while performing a web request.
8    #[error("{0}")]
9    Request(reqwest::Error),
10    /// The request response
11    #[error("The request response could not provide a content-length")]
12    NoContentLength,
13    /// IO error from interacting with files
14    #[error("{0}")]
15    Io(std::io::Error),
16    /// The checksum of the downloaded file does not match the provided one.
17    #[error("The Checksums do not match")]
18    ChecksumMismatch,
19}
20
21impl From<reqwest::Error> for DownloadError {
22    fn from(err: reqwest::Error) -> Self {
23        Self::Request(err)
24    }
25}
26
27impl From<std::io::Error> for DownloadError {
28    fn from(err: std::io::Error) -> Self {
29        Self::Io(err)
30    }
31}