Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useful messages when command line preprocessor fails #1526

Merged
merged 1 commit into from
May 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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