Skip to content

Commit

Permalink
Merge pull request #2110 from abrauchli/err-if-stats-fails
Browse files Browse the repository at this point in the history
`schema`: Print an error if the `qsv stats` invocation fails
  • Loading branch information
jqnatividad committed Sep 7, 2024
2 parents 902c081 + ef916c4 commit cabfe5a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[cfg(any(feature = "feature_capable", feature = "lite"))]
use std::borrow::Cow;
#[cfg(target_family = "unix")]
use std::os::unix::process::ExitStatusExt;
use std::{
cmp::min,
env, fs,
Expand Down Expand Up @@ -2080,7 +2082,33 @@ pub fn get_stats_records(
let qsv_bin = std::env::current_exe().unwrap();
let mut stats_cmd = std::process::Command::new(qsv_bin);
stats_cmd.args(stats_args_vec);
let _stats_output = stats_cmd.output()?;
let status = stats_cmd.output()?.status;
if !status.success() {
let status_code = status.code();
if let Some(code) = status_code {
return Err(CliError::Other(
format!("qsv stats exited with code: {}", code).to_string(),
));
}
#[cfg(target_family = "unix")]
{
if let Some(signal) = status.signal() {
return Err(CliError::Other(
format!("qsv stats terminated with signal: {}", signal).to_string(),
));
} else {
return Err(CliError::Other(
"qsv stats terminated by unknown cause".to_string(),
));
}
}
#[cfg(not(target_family = "unix"))]
{
return Err(CliError::Other(
"qsv stats terminated by unknown cause".to_string(),
));
}
}

// create a statsdatajon from the output of the stats command
csv_to_jsonl(
Expand Down

0 comments on commit cabfe5a

Please sign in to comment.