From b21446898a81ca1be8a2732323d027cacd8ad1a7 Mon Sep 17 00:00:00 2001 From: apatniv Date: Sat, 8 May 2021 11:49:11 -0400 Subject: [PATCH] Add useful messages when command line preprocessor fails --- src/preprocess/cmd.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/preprocess/cmd.rs b/src/preprocess/cmd.rs index f9c64e28cb..44654ffe4d 100644 --- a/src/preprocess/cmd.rs +++ b/src/preprocess/cmd.rs @@ -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 {