Improve error handling in compare.
This commit is contained in:
parent
f376f1cf8e
commit
ac313d093e
@ -66,7 +66,6 @@ use crate::parser::VerseBlock;
|
||||
pub struct DiffResult {
|
||||
status: DiffStatus,
|
||||
name: String,
|
||||
#[allow(dead_code)]
|
||||
message: Option<String>,
|
||||
children: Vec<DiffResult>,
|
||||
}
|
||||
@ -178,7 +177,7 @@ fn compare_element<'s>(
|
||||
emacs: &'s Token<'s>,
|
||||
rust: &'s Element<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
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<DiffResult, Box<dyn std::error::Error>> {
|
||||
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(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user