LibWeb: Improve error message for IDL generation with missing interface

Instead of a cryptic error that occurs due to an interface with no name,
fail early on by explicitly checking that an interface was parsed with a
name.
This commit is contained in:
Shannon Booth 2024-04-21 12:34:56 +12:00 committed by Andreas Kling
commit 10add8aa8a
Notes: sideshowbarker 2024-07-17 04:10:16 +09:00

View file

@ -434,8 +434,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// TODO: service_worker_exposed
for (size_t i = 0; i < paths.size(); ++i) {
IDL::Parser parser(paths[i], file_contents[i], lexical_base.string());
TRY(add_to_interface_sets(parser.parse(), intrinsics, window_exposed, dedicated_worker_exposed, shared_worker_exposed));
auto const& path = paths[i];
IDL::Parser parser(path, file_contents[i], lexical_base.string());
auto& interface = parser.parse();
if (interface.name.is_empty()) {
s_error_string = ByteString::formatted("Interface for file {} missing", path);
return Error::from_string_view(s_error_string.view());
}
TRY(add_to_interface_sets(interface, intrinsics, window_exposed, dedicated_worker_exposed, shared_worker_exposed));
parsers.append(move(parser));
}