LibJS+LibWeb: Make DOMException hold an [[ErrorData]] slot

Split JS::ErrorData out of JS::Error so that it can be used both
by JS::Error and WebIDL::DOMException. This adds support for
Error.isError to DOMException, also letting us report DOMException
stack information to the console.
This commit is contained in:
Shannon Booth
2026-04-04 15:39:01 +02:00
committed by Shannon Booth
parent bdd9c98d44
commit 57130908b3
Notes: github-actions[bot] 2026-04-08 18:35:02 +00:00
24 changed files with 429 additions and 152 deletions

View File

@@ -10,6 +10,7 @@
#include <AK/MemoryStream.h>
#include <LibJS/Print.h>
#include <LibJS/Runtime/BigInt.h>
#include <LibJS/Runtime/ErrorData.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
#include <LibWeb/HTML/Window.h>
@@ -99,17 +100,12 @@ void DevToolsConsoleClient::handle_result(JS::Value result)
m_client->did_execute_js_console_input(serialize_js_value(m_realm, result));
}
void DevToolsConsoleClient::report_exception(JS::Error const& exception, bool in_promise)
void DevToolsConsoleClient::report_exception(String const& name, String const& message, JS::ErrorData const& error_data, bool in_promise)
{
auto& vm = exception.vm();
auto name = exception.get_without_side_effects(vm.names.name);
auto message = exception.get_without_side_effects(vm.names.message);
Vector<WebView::StackFrame> trace;
trace.ensure_capacity(exception.traceback().size());
trace.ensure_capacity(error_data.traceback().size());
for (auto const& frame : exception.traceback()) {
for (auto const& frame : error_data.traceback()) {
auto const& source_range = frame.source_range();
WebView::StackFrame stack_frame;
@@ -129,8 +125,8 @@ void DevToolsConsoleClient::report_exception(JS::Error const& exception, bool in
send_console_output({
.timestamp = UnixDateTime::now(),
.output = WebView::ConsoleError {
.name = name.to_string_without_side_effects(),
.message = message.to_string_without_side_effects(),
.name = name,
.message = message,
.trace = move(trace),
.inside_promise = in_promise,
},

View File

@@ -29,7 +29,7 @@ private:
DevToolsConsoleClient(JS::Realm&, JS::Console&, PageClient&, ConsoleGlobalEnvironmentExtensions&);
virtual void handle_result(JS::Value) override;
virtual void report_exception(JS::Error const&, bool) override;
virtual void report_exception(String const& name, String const& message, JS::ErrorData const&, bool) override;
virtual void end_group() override { }
virtual void clear() override { }