JSSpecCompiler: Start converting crashes to error messages

I got fed up with looking at error messages that tell me "VERIFICATION
FAILED: !is_error()". So this commit introduces DiagnosticEngine class
whose purpose is to accumulate and print more user-friendly errors.
This commit is contained in:
Dan Klishch 2024-01-18 21:09:53 -05:00 committed by Andrew Kaster
parent 3aec6952a2
commit 0806ccaeec
Notes: sideshowbarker 2024-07-16 22:22:13 +09:00
8 changed files with 262 additions and 4 deletions

View file

@ -136,6 +136,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto const& step : pipeline.pipeline()) {
step.step->run(&translation_unit);
if (translation_unit.diag().has_fatal_errors()) {
translation_unit.diag().print_diagnostics();
return 1;
}
if (step.dump_ast) {
outln(stderr, "===== AST after {} =====", step.step->name());
for (auto const& function : translation_unit.functions_to_compile()) {
@ -152,5 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
translation_unit.diag().print_diagnostics();
return 0;
}