summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-05-06 09:13:46 +0300
committerLars Wirzenius <liw@liw.fi>2022-05-06 09:34:28 +0300
commit2a452b2d2f4fba6f840e2ea33123002ae58e88b2 (patch)
tree2d92f01ee2e8bec3bf5bd17b271232a7504a1383
parent2b7160ebdf950ef872f785336fcfe17e0c4cb347 (diff)
downloadsubplot-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.rs2
-rw-r--r--src/error.rs13
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
///