feat: better error message for validation failure

This commit is contained in:
PoiScript 2019-11-05 17:04:03 +08:00
parent e4204729c2
commit 5d5fc58027

View file

@ -185,11 +185,13 @@ impl Org<'_> {
if cfg!(debug_assertions) {
let errors = self.validate();
if !errors.is_empty() {
eprintln!("Validation failed. {} error(s) found:", errors.len());
for err in &errors {
eprintln!("Org validation failed. {} error(s) found:", errors.len());
for err in errors {
eprintln!("{:?} at {:?}", err, err.element(self));
}
panic!();
panic!(
"Looks like there's a bug in orgize! Please report it with your org-mode content at https://github.com/PoiScript/orgize/issues."
);
}
}
}