mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 05:27:35 +00:00
LibWeb: Add and use a helper to reject a promise with an exception
This commit is contained in:
parent
24951a039e
commit
4bdb7dba8c
10 changed files with 42 additions and 52 deletions
|
@ -13,7 +13,6 @@
|
|||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/HostDefined.h>
|
||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
namespace Web::WebIDL {
|
||||
|
@ -295,4 +294,11 @@ void wait_for_all(JS::Realm& realm, Vector<JS::NonnullGCPtr<Promise>> const& pro
|
|||
}
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<JS::Promise> create_rejected_promise_from_exception(JS::Realm& realm, Exception exception)
|
||||
{
|
||||
auto throw_completion = Bindings::dom_exception_to_throw_completion(realm.vm(), move(exception));
|
||||
auto promise_capability = WebIDL::create_rejected_promise(realm, *throw_completion.value());
|
||||
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise_capability->promise().ptr()) };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue