Skip to content

Commit

Permalink
Merge pull request #1526 from apatniv/add_log_messages
Browse files Browse the repository at this point in the history
Add useful messages when command line preprocessor fails
  • Loading branch information
ehuss authored May 21, 2021
2 parents b364e8e + b214468 commit 7e7e779
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/preprocess/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,28 @@ impl Preprocessor for CmdPreprocessor {

self.write_input_to_child(&mut child, &book, ctx);

let output = child
.wait_with_output()
.with_context(|| "Error waiting for the preprocessor to complete")?;
let output = child.wait_with_output().with_context(|| {
format!(
"Error waiting for the \"{}\" preprocessor to complete",
self.name
)
})?;

trace!("{} exited with output: {:?}", self.cmd, output);
ensure!(
output.status.success(),
"The preprocessor exited unsuccessfully"
format!(
"The \"{}\" preprocessor exited unsuccessfully with {} status",
self.name, output.status
)
);

serde_json::from_slice(&output.stdout)
.with_context(|| "Unable to parse the preprocessed book")
serde_json::from_slice(&output.stdout).with_context(|| {
format!(
"Unable to parse the preprocessed book from \"{}\" processor",
self.name
)
})
}

fn supports_renderer(&self, renderer: &str) -> bool {
Expand Down

0 comments on commit 7e7e779

Please sign in to comment.