From dc0ee6ce99a0480b7a6c228492936b16ceaf60cd Mon Sep 17 00:00:00 2001 From: Naz Date: Sun, 3 Aug 2025 10:06:33 +0100 Subject: =?UTF-8?q?=E2=9C=A8feat:=20add=20a=20more=20spesific=20error=20fo?= =?UTF-8?q?r=20the=20download=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/error.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 39c421d..b473469 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,6 +6,10 @@ pub type Result = core::result::Result; pub enum Error { InvalidPath, NotFound(String), + Download { + url: String, + source: reqwest::Error, + }, #[from] Io(std::io::Error), @@ -36,6 +40,22 @@ impl core::fmt::Display for Error { Error::EnvVar(e) => write!(fmt, "Environment variable error: {e}"), Error::InvalidPath => write!(fmt, "Invalid path provided"), Error::IndicatifTemplate(e) => write!(fmt, "Progress bar template error: {e}"), + Error::Download { url, source } => { + if source.is_timeout() { + write!(fmt, "Download timed out from: {url}") + } else if source.is_connect() { + write!(fmt, "Failed to connect to: {url}") + } else if let Some(status) = source.status() { + match status.as_u16() { + 404 => write!(fmt, "AppImage not found at: {url}"), + 403 => write!(fmt, "Access denied at: {url}"), + 500..=599 => write!(fmt, "Server error when downloading from: {url}"), + _ => write!(fmt, "HTTP {status} error downloading from: {url}"), + } + } else { + write!(fmt, "Failed to download from {url}: {source}") + } + } } } } -- cgit v1.2.3