From da068a43c1fc4c349875d2cdab90a2c41af430c0 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Sun, 27 Jan 2019 16:03:18 +0100 Subject: [PATCH] Moved function call to get_icon_url to prevent error bubbeling --- src/api/icons.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/icons.rs b/src/api/icons.rs index 540be039..0cf34d39 100644 --- a/src/api/icons.rs +++ b/src/api/icons.rs @@ -55,10 +55,8 @@ fn get_icon(domain: &str) -> Vec { return icon; } - let url = get_icon_url(&domain).unwrap(); - // Get the icon, or fallback in case of error - match download_icon(&url) { + match download_icon(&domain) { Ok(icon) => { save_icon(&path, &icon); icon @@ -284,9 +282,11 @@ fn fix_href(href: &str, url: &str) -> String { } } -fn download_icon(url: &str) -> Result, Error> { - info!("Downloading icon for {}...", url); - let mut res = reqwest::get(url)?; +fn download_icon(domain: &str) -> Result, Error> { + let url = get_icon_url(&domain).unwrap(); + + info!("Downloading icon for {} via {}...",domain, url); + let mut res = reqwest::get(&url)?; res = res.error_for_status()?;