From ca8459dc7b8d07a5f276a4646ddf634a4cc8b700 Mon Sep 17 00:00:00 2001 From: lyken Date: Wed, 26 Jun 2024 16:45:35 +0800 Subject: [PATCH] standalone: prettify TopLevelComposer error reporting --- nac3standalone/src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index 506b62a10..c2a1d1947 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -340,7 +340,19 @@ fn main() { let signature = store.from_signature(&mut composer.unifier, &primitive, &signature, &mut cache); let signature = store.add_cty(signature); - composer.start_analysis(true).unwrap(); + if let Err(errors) = composer.start_analysis(true) { + let error_count = errors.len(); + eprintln!("{error_count} error(s) occurred during top level analysis."); + + for (error_i, error) in errors.iter().enumerate() { + let error_num = error_i + 1; + eprintln!("=========== ERROR {error_num}/{error_count} ============"); + eprintln!("{error}"); + } + eprintln!("=================================="); + + panic!("top level analysis failed"); + } let top_level = Arc::new(composer.make_top_level_context());