From 10add8aa8a8d3ea7d72b6e5564827fb357637b6b Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 21 Apr 2024 12:34:56 +1200 Subject: [PATCH] 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. --- .../LibWeb/GenerateWindowOrWorkerInterfaces.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 341910da080..a24df9838f6 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -434,8 +434,15 @@ ErrorOr 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)); }