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:
1 parent
66aae232c5
commit
2ca4151444
1 file changed
+9
-3
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user