From 52ccfa5a1bf2893bdc63ff1bad2b2a88ca86ef95 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 6 May 2022 09:56:18 +0300 Subject: refactor: replace SubplotError::JsonError with a more specific one SubplotError::JsonError is a generic error, but we actually only parse JSON when parsing the AST from Pandoc. Replace it with a ::AstJson error to be more specific, and hopefully more helpful to the user. Sponsored-by: author --- src/error.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/error.rs') 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")] -- cgit v1.2.1