fix(calendar): fall back to stdout when readpst's stderr is empty

readpst writes some failure messages to stdout rather than stderr, so a
failing run with empty stderr surfaced as a blank "parse failed: " error
with no diagnostic content.
This commit is contained in:
iamdoubz committed 2026-07-06 13:56:44 -05:00
1 parent 66aae232c5
commit 2ca4151444
1 file changed
+9 -3
+9 -3
View File
@@ -79,9 +79,15 @@ fn run_readpst(pst_path: &str, out_dir: &Path) -> Result<(), CalError> {
_ => CalError::Open(e.to_string()),
})?;
if !output.status.success() {
return Err(CalError::Parse(
String::from_utf8_lossy(&output.stderr).trim().to_string(),
));
// readpst writes some errors to stdout rather than stderr; show
// whichever stream actually has text, stderr first.
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
let message = if stderr.is_empty() {
String::from_utf8_lossy(&output.stdout).trim().to_string()
} else {
stderr
};
return Err(CalError::Parse(message));
}
Ok(())
}