From 7904c00aa8ed3273aa97264d609e746a13119357 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 22 Jul 2017 16:24:32 +0200 Subject: [PATCH] Improve error handling --- src/errors.rs | 2 ++ src/notif.rs | 13 ++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 3a1d936db..f142789c6 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,7 @@ #![allow(missing_docs)] use alsa_lib; +use glib; use png; use std::convert::From; use std; @@ -14,6 +15,7 @@ error_chain! { IO(std::io::Error); Toml(toml::de::Error); Png(png::DecodingError); + GlibError(glib::Error); } errors { diff --git a/src/notif.rs b/src/notif.rs index 38f868512..670f31241 100644 --- a/src/notif.rs +++ b/src/notif.rs @@ -108,16 +108,13 @@ impl Notif { } }; - // TODO: error handling self.volume_notif - .update(summary.as_str(), None, Some(icon)) - .unwrap(); + .update(summary.as_str(), None, Some(icon))?; self.volume_notif.set_hint( "value", Some((vol as i32).to_variant()), ); - // TODO: error handling - self.volume_notif.show().unwrap(); + self.volume_notif.show()?; return Ok(()); } @@ -125,10 +122,8 @@ impl Notif { /// Shows a text notification, e.g. for warnings or errors. pub fn show_text_notif(&self, summary: &str, body: &str) -> Result<()> { - // TODO: error handling - self.text_notif.update(summary, Some(body), None).unwrap(); - // TODO: error handling - self.text_notif.show().unwrap(); + self.text_notif.update(summary, Some(body), None)?; + self.text_notif.show()?; return Ok(()); }