diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-05-06 09:13:46 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-05-06 09:34:28 +0300 |
commit | 2a452b2d2f4fba6f840e2ea33123002ae58e88b2 (patch) | |
tree | 2d92f01ee2e8bec3bf5bd17b271232a7504a1383 | |
parent | 2b7160ebdf950ef872f785336fcfe17e0c4cb347 (diff) | |
download | subplot-2a452b2d2f4fba6f840e2ea33123002ae58e88b2.tar.gz |
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
-rw-r--r-- | src/doc.rs | 2 | ||||
-rw-r--r-- | src/error.rs | 13 |
2 files changed, 4 insertions, 11 deletions
@@ -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 /// |