aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-02 02:59:56 +0100
committerTeddy Wing2018-11-02 02:59:56 +0100
commite4c21b11069297d289f25834cfc3c001a4604b5f (patch)
tree74e7c03475f06674417fbbdfdfb083e6c5ea898f
parent70e127ba7d9ec2ad7419085d6bcf0e8d96adef47 (diff)
downloaddome-key-map-e4c21b11069297d289f25834cfc3c001a4604b5f.tar.bz2
run_action(): Return `Result`
Instead of handling the error in this function, pass it up to the caller. This will allow the error message to be printed, as we've only allowed 'stderrlog' to print log messages in the `ffi` module.
-rw-r--r--src/map.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/map.rs b/src/map.rs
index 5741245..86d6773 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -3,6 +3,7 @@ use std::ffi::OsString;
use std::process::Command;
use {Action, HeadphoneButton, MapAction, MapKind};
+use errors::*;
use ffi::State;
#[repr(C)]
@@ -54,7 +55,7 @@ pub fn run_key_action<'a>(
}
}
-fn run_action(map_action: &MapAction) {
+fn run_action(map_action: &MapAction) -> Result<()> {
match map_action.kind {
MapKind::Map => {
if let Action::Map(action) = &map_action.action {
@@ -70,17 +71,15 @@ fn run_action(map_action: &MapAction) {
None => OsString::from("/bin/sh"),
};
- match Command::new(shell)
+ return Command::new(shell)
.arg("-c")
.arg(action)
- .spawn() {
- Ok(_) => (),
- Err(e) => error!(
- "Command failed to start: `{}'",
- e
- ),
- }
+ .spawn()
+ .map(|_| ())
+ .chain_err(|| "command failed to start");
}
},
- }
+ };
+
+ Ok(())
}