mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 12:07:14 +02:00
LibWeb: Add a convenience method to reject a promise with an exception
This commit is contained in:
committed by
Shannon Booth
parent
0e76d7c8c8
commit
3fefe7b59f
Notes:
github-actions[bot]
2026-04-03 09:06:56 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/3fefe7b59fb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8745 Reviewed-by: https://github.com/shannonbooth ✅
@@ -333,4 +333,10 @@ GC::Ref<Promise> create_rejected_promise_from_exception(JS::Realm& realm, Except
|
||||
return WebIDL::create_rejected_promise(realm, throw_completion.value());
|
||||
}
|
||||
|
||||
void reject_promise_with_exception(JS::Realm& realm, Promise const& promise, Exception exception)
|
||||
{
|
||||
auto throw_completion = Bindings::exception_to_throw_completion(realm.vm(), move(exception));
|
||||
WebIDL::reject_promise(realm, promise, throw_completion.value());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ WEB_API bool is_promise_fulfilled(Promise const&);
|
||||
WEB_API void wait_for_all(JS::Realm&, ReadonlySpan<GC::Ref<Promise>> promises, Function<void(Vector<JS::Value> const&)> success_steps, Function<void(JS::Value)> failure_steps);
|
||||
WEB_API GC::Ref<Promise> get_promise_for_wait_for_all(JS::Realm&, ReadonlySpan<GC::Ref<Promise>> promises);
|
||||
|
||||
// Non-spec, convenience method.
|
||||
// Non-spec, convenience methods.
|
||||
WEB_API GC::Ref<Promise> create_rejected_promise_from_exception(JS::Realm&, Exception);
|
||||
WEB_API void reject_promise_with_exception(JS::Realm&, Promise const&, Exception);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user