1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-03 19:51:03 +02:00

fix: poor error handling for missing images

Previously images that could not be located were handled by throwing a
full report error, which incorrectly stated it was an invalid image
*type*.

This changes the image handling to instead log a single-line warning
directly in the image provider code, reducing the error handling
required by each consumer.

Resolves #146.
This commit is contained in:
Jake Stanger 2023-05-20 14:36:04 +01:00
parent 960da55a05
commit 87ca399220
7 changed files with 52 additions and 62 deletions

View file

@ -5,7 +5,6 @@ use crate::image::ImageProvider;
use gtk::prelude::*;
use gtk::Image;
use serde::Deserialize;
use tracing::error;
#[derive(Debug, Deserialize, Clone)]
pub struct ImageWidget {
@ -31,12 +30,8 @@ impl CustomWidget for ImageWidget {
let icon_theme = context.icon_theme.clone();
DynamicString::new(&self.src, move |src| {
let res = ImageProvider::parse(&src, &icon_theme, self.size)
.and_then(|image| image.load_into_image(gtk_image.clone()));
if let Err(err) = res {
error!("{err:?}");
}
ImageProvider::parse(&src, &icon_theme, self.size)
.map(|image| image.load_into_image(gtk_image.clone()));
Continue(true)
});