From 1d53fc9fa8166eda04d63bd270401fb7995e7de5 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 30 Oct 2023 09:35:10 -0500 Subject: [PATCH] fixing error handling in obs.rs --- src/rust/obs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rust/obs.rs b/src/rust/obs.rs index 15d0f58..5472cf6 100644 --- a/src/rust/obs.rs +++ b/src/rust/obs.rs @@ -18,21 +18,21 @@ impl Obs { Ok(()) } - pub fn get_list(self) -> Result, String> { + pub fn get_list(self) -> Result, Box> { let scenes = self.scenes.scenes.iter().map(|x| x.name).collect::>(); if scenes.len() > 0 { Ok(scenes) } else { - Err(format!("Scenes found: {}", scenes.len())) + Err(format!("Scenes found: {}", scenes.len()))? } } - pub fn set_scene(self, scene: String) -> Result<(), String> { + pub fn set_scene(self, scene: String) -> Result<(), Box> { if let Some(scene) = self.scenes.scenes.iter().filter(|x| x.name == scene).next() { self.client.scenes().set_current_program_scene(scene.name.as_str()); Ok(()) } else { - Err("Couldn't set the scene".to_string()) + Err("Couldn't set the scene".to_owned())? } } }