Skip to content

Commit 7e7e779

Browse files
authored
Merge pull request #1526 from apatniv/add_log_messages
Add useful messages when command line preprocessor fails
2 parents b364e8e + b214468 commit 7e7e779

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/preprocess/cmd.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,28 @@ impl Preprocessor for CmdPreprocessor {
109109

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

112-
let output = child
113-
.wait_with_output()
114-
.with_context(|| "Error waiting for the preprocessor to complete")?;
112+
let output = child.wait_with_output().with_context(|| {
113+
format!(
114+
"Error waiting for the \"{}\" preprocessor to complete",
115+
self.name
116+
)
117+
})?;
115118

116119
trace!("{} exited with output: {:?}", self.cmd, output);
117120
ensure!(
118121
output.status.success(),
119-
"The preprocessor exited unsuccessfully"
122+
format!(
123+
"The \"{}\" preprocessor exited unsuccessfully with {} status",
124+
self.name, output.status
125+
)
120126
);
121127

122-
serde_json::from_slice(&output.stdout)
123-
.with_context(|| "Unable to parse the preprocessed book")
128+
serde_json::from_slice(&output.stdout).with_context(|| {
129+
format!(
130+
"Unable to parse the preprocessed book from \"{}\" processor",
131+
self.name
132+
)
133+
})
124134
}
125135

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

0 commit comments

Comments
 (0)