diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 5c22d63..037d826 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -66,7 +66,6 @@ use crate::parser::VerseBlock; pub struct DiffResult { status: DiffStatus, name: String, - #[allow(dead_code)] message: Option, children: Vec, } @@ -178,7 +177,7 @@ fn compare_element<'s>( emacs: &'s Token<'s>, rust: &'s Element<'s>, ) -> Result> { - match rust { + let compare_result = match rust { Element::Paragraph(obj) => compare_paragraph(source, emacs, obj), Element::PlainList(obj) => compare_plain_list(source, emacs, obj), Element::GreaterBlock(obj) => compare_greater_block(source, emacs, obj), @@ -200,6 +199,15 @@ fn compare_element<'s>( Element::HorizontalRule(obj) => compare_horizontal_rule(source, emacs, obj), Element::Keyword(obj) => compare_keyword(source, emacs, obj), Element::LatexEnvironment(obj) => compare_latex_environment(source, emacs, obj), + }; + match compare_result { + Ok(_) => compare_result, + Err(ref e) => Ok(DiffResult { + status: DiffStatus::Bad, + name: "error!".to_owned(), + message: Some(e.to_string()), + children: Vec::new(), + }), } } @@ -208,7 +216,7 @@ fn compare_object<'s>( emacs: &'s Token<'s>, rust: &'s Object<'s>, ) -> Result> { - match rust { + let compare_result = match rust { Object::Bold(obj) => compare_bold(source, emacs, obj), Object::Italic(obj) => compare_italic(source, emacs, obj), Object::Underline(obj) => compare_underline(source, emacs, obj), @@ -236,6 +244,15 @@ fn compare_object<'s>( Object::Subscript(obj) => compare_subscript(source, emacs, obj), Object::Superscript(obj) => compare_superscript(source, emacs, obj), Object::Timestamp(obj) => compare_timestamp(source, emacs, obj), + }; + match compare_result { + Ok(_) => compare_result, + Err(ref e) => Ok(DiffResult { + status: DiffStatus::Bad, + name: "error!".to_owned(), + message: Some(e.to_string()), + children: Vec::new(), + }), } }