improve invoke error reporting

This commit is contained in:
Aiden McClelland
2023-06-15 22:26:53 -06:00
committed by Aiden McClelland
parent cb4e12a68c
commit a2cf4001af
2 changed files with 32 additions and 9 deletions

View File

@@ -58,7 +58,12 @@ impl Invoke for tokio::process::Command {
res.status.success(),
error_kind,
"{}",
std::str::from_utf8(&res.stderr).unwrap_or("Unknown Error")
Some(&res.stderr)
.filter(|a| !a.is_empty())
.or(Some(&res.stdout))
.filter(|a| !a.is_empty())
.and_then(|a| std::str::from_utf8(a).ok())
.unwrap_or(&format!("Unknown Error ({})", res.status))
);
Ok(res.stdout)
}