Clean up unwrap()'s. Print out info in asusctl if error

This commit is contained in:
Luke D. Jones
2021-08-28 11:07:47 +12:00
parent 3d41a7978a
commit c6cc304a42
17 changed files with 143 additions and 70 deletions

View File

@@ -1,3 +1,4 @@
use rog_anime::error::AnimeError;
use rog_anime::{ActionData, ActionLoader, AnimTime, Fade, Sequences, Vec2};
use rog_dbus::RogDbusClient;
use serde_derive::{Deserialize, Serialize};
@@ -91,16 +92,19 @@ impl<'a> CtrlAnimeInner<'static> {
match action {
ActionData::Animation(frames) => {
rog_anime::run_animation(frames, self.do_early_return.clone(), &|output| {
self.client.proxies().anime().write(output).unwrap()
})
.unwrap();
self.client
.proxies()
.anime()
.write(output)
.map_err(|e| AnimeError::Dbus(format!("{}", e)))
})?;
}
ActionData::Image(image) => {
self.client
.proxies()
.anime()
.write(image.as_ref().clone())
.unwrap();
.ok();
}
ActionData::Pause(duration) => {
let start = Instant::now();

View File

@@ -17,7 +17,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" rog-dbus v{}", rog_dbus::VERSION);
println!("rog-supported v{}", rog_supported::VERSION);
let (client, _) = RogDbusClient::new().unwrap();
let (client, _) = RogDbusClient::new()?;
let supported = client.proxies().supported().get_supported_functions()?;
let mut config = UserConfig::new();
@@ -44,7 +44,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
early_return.clone(),
)?));
// Need new client object for dbus control part
let (client, _) = RogDbusClient::new().unwrap();
let (client, _) = RogDbusClient::new()?;
let anime_control = CtrlAnime::new(anime_config, inner.clone(), client, early_return)?;
anime_control.add_to_server(&mut server);
// Thread using inner
@@ -52,7 +52,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.name("Anime User".into())
.spawn(move || loop {
if let Ok(inner) = inner.try_lock() {
inner.run().unwrap();
inner.run().ok();
}
})?;
}