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(())
|
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>>();
|
let scenes = self.scenes.scenes.iter().map(|x| x.name).collect::<Vec<String>>();
|
||||||
if scenes.len() > 0 {
|
if scenes.len() > 0 {
|
||||||
Ok(scenes)
|
Ok(scenes)
|
||||||
} else {
|
} 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() {
|
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());
|
self.client.scenes().set_current_program_scene(scene.name.as_str());
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} 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