mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
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.)
This commit is contained in:
parent
3383ae1598
commit
4db5406d62
2 changed files with 12 additions and 4 deletions
|
@ -12,12 +12,13 @@
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#report-the-exception
|
// 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: 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.
|
// FIXME: We should probably also report these exceptions to the JS console.
|
||||||
VERIFY(result.throw_completion().value().has_value());
|
VERIFY(throw_completion.type() == JS::Completion::Type::Throw);
|
||||||
auto thrown_value = *result.throw_completion().value();
|
VERIFY(throw_completion.value().has_value());
|
||||||
|
auto thrown_value = *throw_completion.value();
|
||||||
if (thrown_value.is_object()) {
|
if (thrown_value.is_object()) {
|
||||||
auto& object = thrown_value.as_object();
|
auto& object = thrown_value.as_object();
|
||||||
auto& vm = object.vm();
|
auto& vm = object.vm();
|
||||||
|
|
|
@ -10,6 +10,13 @@
|
||||||
|
|
||||||
namespace Web::HTML {
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue