Improve error handling

This commit is contained in:
Julian Ospald 2017-07-22 16:24:32 +02:00
parent 01a8a57235
commit 7904c00aa8
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 6 additions and 9 deletions

View File

@ -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 {

View File

@ -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(());
}