LibWeb: Add a convenience method to reject a promise with an exception
This commit is contained in:
parent
0e76d7c8c8
commit
3fefe7b59f
2 changed files with 8 additions and 1 deletions
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue