mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-11-02 14:20:58 +00:00
LibWeb: Add and use a helper to reject a promise with an exception
This commit is contained in:
parent
24951a039e
commit
4bdb7dba8c
Notes:
sideshowbarker
2024-07-17 00:59:43 +09:00
Author: https://github.com/AtkinsSJ
Commit: 4bdb7dba8c
Pull-request: https://github.com/SerenityOS/serenity/pull/23526
Reviewed-by: https://github.com/trflynn89 ✅
10 changed files with 42 additions and 52 deletions
|
|
@ -340,10 +340,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> HTMLMediaElement::play()
|
|||
// 2. If the media element's error attribute is not null and its code is MEDIA_ERR_SRC_NOT_SUPPORTED, then return a promise
|
||||
// rejected with a "NotSupportedError" DOMException.
|
||||
if (m_error && m_error->code() == MediaError::Code::SrcNotSupported) {
|
||||
auto error = WebIDL::NotSupportedError::create(realm, m_error->message());
|
||||
auto promise = WebIDL::create_rejected_promise(realm, error);
|
||||
|
||||
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise->promise()) };
|
||||
auto exception = WebIDL::NotSupportedError::create(realm, m_error->message());
|
||||
return WebIDL::create_rejected_promise_from_exception(realm, move(exception));
|
||||
}
|
||||
|
||||
// 3. Let promise be a new promise and append promise to the list of pending play promises.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue