Skip to content

Commit

Permalink
Merge pull request #278 from losynix/cmdexec_err
Browse files Browse the repository at this point in the history
More verbose err message if cmd failed
  • Loading branch information
losynix committed Aug 2, 2023
2 parents cb2fe9a + c232f4c commit 63dd4ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions usbsas-cmdexec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ impl RunningState {

fn exec_cmd(&self, binpath: String, args: Vec<String>) -> Result<()> {
info!("executing {} {:?}", binpath, args);
if let Ok(cmd) = Command::new(binpath)
match Command::new(binpath)
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
{
match cmd.wait_with_output() {
Ok(cmd) => match cmd.wait_with_output() {
Ok(output) => {
if !output.status.success() {
error!("cmd failed");
Expand All @@ -183,14 +183,11 @@ impl RunningState {
}
return Err(Error::Exec("Cmd failed".into()));
}
Ok(())
}
Err(err) => {
return Err(Error::Exec(format!("Can't get cmd result: {err}")));
}
}
Ok(())
} else {
Err(Error::Exec("Failed to start child cmd".into()))
Err(err) => Err(Error::Exec(format!("Can't get cmd result: {err}"))),
},
Err(err) => Err(Error::Exec(format!("Failed to start child cmd: {err}"))),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion usbsas-usbsas/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2244,7 +2244,7 @@ struct OutFiles {

fn main() -> Result<()> {
let session_id = match env::var("USBSAS_SESSION_ID") {
Ok(id) => id.to_string(),
Ok(id) => id,
Err(_) => {
let id = uuid::Uuid::new_v4().simple().to_string();
env::set_var("USBSAS_SESSION_ID", &id);
Expand Down

0 comments on commit 63dd4ca

Please sign in to comment.