diff --git a/CHANGELOG.md b/CHANGELOG.md index d511387..a0599f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # unreleased +- Add command exit code to output if it fails, see #342 (@KaindlJulian) + ## Features ## Changes diff --git a/src/hyperfine/benchmark.rs b/src/hyperfine/benchmark.rs index db885c9..446d75d 100644 --- a/src/hyperfine/benchmark.rs +++ b/src/hyperfine/benchmark.rs @@ -63,9 +63,15 @@ pub fn time_shell_command( if failure_action == CmdFailureAction::RaiseError && !result.status.success() { return Err(io::Error::new( io::ErrorKind::Other, - "Command terminated with non-zero exit code. \ - Use the '-i'/'--ignore-failure' option if you want to ignore this. \ - Alternatively, use the '--show-output' option to debug what went wrong.", + format!( + "{}. \ + Use the '-i'/'--ignore-failure' option if you want to ignore this. \ + Alternatively, use the '--show-output' option to debug what went wrong.", + result.status.code().map_or( + "The process has been terminated by a signal".into(), + |c| format!("Command terminated with non-zero exit code: {}", c) + ) + ), )); }