summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/doc.rs4
-rw-r--r--src/error.rs13
2 files changed, 5 insertions, 12 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 71910f1..490a613 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -146,7 +146,7 @@ impl<'a> Document {
P: AsRef<Path> + Debug,
{
trace!("Parsing document...");
- let ast: Pandoc = serde_json::from_str(json)?;
+ let ast: Pandoc = serde_json::from_str(json).map_err(SubplotError::AstJson)?;
Self::from_ast(basedir, markdowns, ast, style, template)
}
@@ -217,7 +217,7 @@ impl<'a> Document {
/// This is useful in a Pandoc filter, so that the filter can give
/// it back to Pandoc for typesetting.
pub fn ast(&self) -> Result<String, SubplotError> {
- let json = serde_json::to_string(&self.ast)?;
+ let json = serde_json::to_string(&self.ast).map_err(SubplotError::AstJson)?;
Ok(json)
}
diff --git a/src/error.rs b/src/error.rs
index 8fdaeee..a42298d 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -294,16 +294,9 @@ pub enum SubplotError {
#[error("Failed to compile regular expression: {0:?}")]
Regex(String, #[source] regex::Error),
- /// JSON error
- ///
- /// Subplot parses and generates JSON. This is a generic wrapper
- /// for any kinds of errors related to that.
- #[error(transparent)]
- JsonError {
- /// The wrapped error.
- #[from]
- source: serde_json::Error,
- },
+ /// Error parsing the Pandoc abstract syntax tree as JSON.
+ #[error("Failed to parse document AST as JSON")]
+ AstJson(#[source] serde_json::Error),
/// Error parsing YAML metadata for document.
#[error("Failed to parse YAML metadata")]