Skip to content

Commit

Permalink
uh: More informative error message for when installation_set::active …
Browse files Browse the repository at this point in the history
…fails

Signed-off-by: Jonathas-Conceicao <jonathas.conceicao@ossystems.com.br>
  • Loading branch information
Jonathas-Conceicao committed Aug 19, 2021
1 parent cfd34b0 commit 6239b05
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions updatehub/src/firmware/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ pub(crate) fn run_hooks_from_dir(path: &Path) -> Result<MetadataValue> {
}

pub(crate) fn run_script(cmd: &str) -> Result<String> {
let output = easy_process::run(cmd)?;
if !output.stderr.is_empty() {
output.stderr.lines().for_each(|err| error!("{} (stderr): {}", cmd, err))
match easy_process::run(cmd) {
Ok(output) => Ok(output.stdout.trim().into()),
Err(easy_process::Error::Io(e)) => {
error!("Failed to run {}: {}", cmd, e);
Err(easy_process::Error::Io(e).into())
}
Err(easy_process::Error::Failure(status, output)) => {
error!("Script {} failed to run: {}", cmd, status);
if !output.stderr.is_empty() {
output.stderr.lines().for_each(|err| error!("{} (stderr): {}", cmd, err))
}
Err(easy_process::Error::Failure(status, output).into())
}
}

Ok(output.stdout.trim().into())
}

fn metadata_value_from_str(s: &str) -> io::Result<MetadataValue> {
Expand Down

0 comments on commit 6239b05

Please sign in to comment.