fixing error handling in obs.rs
This commit is contained in:
parent
c6c3ed5d42
commit
1d53fc9fa8
1 changed files with 4 additions and 4 deletions
|
@ -18,21 +18,21 @@ impl Obs {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_list(self) -> Result<Vec<String>, String> {
|
||||
pub fn get_list(self) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
let scenes = self.scenes.scenes.iter().map(|x| x.name).collect::<Vec<String>>();
|
||||
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<dyn Error>> {
|
||||
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())?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue