From 2a452b2d2f4fba6f840e2ea33123002ae58e88b2 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 6 May 2022 09:13:46 +0300 Subject: refactor: replace generic Pandoc error with specific Replace SubplotError::PandocError with ::Pandoc, which is only for executing the Pandoc program. In reality, so was the old variant, but the new one is more specific, and also embeds the error from executing Pandoc as a source error. The error message is still crap, but that will be fixed later by not using Pandoc for parsing Markdown. Sponsored-by: author --- src/doc.rs | 2 +- src/error.rs | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/doc.rs b/src/doc.rs index 37f32d6..71910f1 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -181,7 +181,7 @@ impl<'a> Document { crate::policy::add_citeproc(&mut pandoc); trace!("Invoking Pandoc to parse document {:?}", filename); - let output = match pandoc.execute()? { + let output = match pandoc.execute().map_err(SubplotError::Pandoc)? { pandoc::PandocOutput::ToBuffer(o) => o, _ => return Err(SubplotError::NotJson), }; diff --git a/src/error.rs b/src/error.rs index f0d76e3..1b95f1c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -283,16 +283,9 @@ pub enum SubplotError { #[error("Error when writing to {0}")] WriteFile(PathBuf, #[source] std::io::Error), - /// Pandoc error - /// - /// Subplot got an error from Panoc. This is a generic wrapper for - /// any kinds of Pandoc errors. - #[error(transparent)] - PandocError { - /// The wrapped error. - #[from] - source: pandoc::PandocError, - }, + /// Error executing Pandoc. + #[error("Pandoc failed")] + Pandoc(#[source] pandoc::PandocError), /// Regular expression error /// -- cgit v1.2.1