Merge pull request #1526 from apatniv/add_log_messages

Add useful messages when command line preprocessor fails
This commit is contained in:
Eric Huss 2021-05-21 10:06:36 -07:00 committed by GitHub
commit 7e7e779ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 6 deletions

View File

@ -109,18 +109,28 @@ impl Preprocessor for CmdPreprocessor {
self.write_input_to_child(&mut child, &book, ctx); self.write_input_to_child(&mut child, &book, ctx);
let output = child let output = child.wait_with_output().with_context(|| {
.wait_with_output() format!(
.with_context(|| "Error waiting for the preprocessor to complete")?; "Error waiting for the \"{}\" preprocessor to complete",
self.name
)
})?;
trace!("{} exited with output: {:?}", self.cmd, output); trace!("{} exited with output: {:?}", self.cmd, output);
ensure!( ensure!(
output.status.success(), output.status.success(),
"The preprocessor exited unsuccessfully" format!(
"The \"{}\" preprocessor exited unsuccessfully with {} status",
self.name, output.status
)
); );
serde_json::from_slice(&output.stdout) serde_json::from_slice(&output.stdout).with_context(|| {
.with_context(|| "Unable to parse the preprocessed book") format!(
"Unable to parse the preprocessed book from \"{}\" processor",
self.name
)
})
} }
fn supports_renderer(&self, renderer: &str) -> bool { fn supports_renderer(&self, renderer: &str) -> bool {