summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-08 15:37:36 +0100
committerLinus Groh <mail@linusgroh.de>2022-02-08 17:47:44 +0000
commit4db5406d6234bad17d34fe8a0b461dea766271e6 (patch)
treec025783c1b011c5fc6704f0cf5a5161509d44a7f /Userland/Libraries
parent3383ae1598434d27c2a185a5498e729f4ce8512c (diff)
downloadserenity-4db5406d6234bad17d34fe8a0b461dea766271e6.zip
LibWeb: Support passing more parameter types to HTML::report_exception()
We now allow any JS::ThrowCompletion<T>, as well as JS::Completion directly (although we'll VERIFY() that it's a throw completion.)
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.cpp7
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.h9
2 files changed, 12 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.cpp
index 8135cb98d9..c5e4802cdd 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.cpp
@@ -12,12 +12,13 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/#report-the-exception
-void report_exception(JS::ThrowCompletionOr<JS::Value> const& result)
+void report_exception(JS::Completion const& throw_completion)
{
// FIXME: This is just old code, and does not strictly follow the spec of report an exception.
// FIXME: We should probably also report these exceptions to the JS console.
- VERIFY(result.throw_completion().value().has_value());
- auto thrown_value = *result.throw_completion().value();
+ VERIFY(throw_completion.type() == JS::Completion::Type::Throw);
+ VERIFY(throw_completion.value().has_value());
+ auto thrown_value = *throw_completion.value();
if (thrown_value.is_object()) {
auto& object = thrown_value.as_object();
auto& vm = object.vm();
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.h b/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.h
index a931ca4575..dc4aad44c8 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.h
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.h
@@ -10,6 +10,13 @@
namespace Web::HTML {
-void report_exception(JS::ThrowCompletionOr<JS::Value> const& value);
+void report_exception(JS::Completion const&);
+
+template<typename T>
+inline void report_exception(JS::ThrowCompletionOr<T> const& result)
+{
+ VERIFY(result.is_throw_completion());
+ report_exception(result.throw_completion());
+}
}