mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
LibWeb: Add and use a helper to reject a promise with an exception
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 00:59:43 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/4bdb7dba8c Pull-request: https://github.com/SerenityOS/serenity/pull/23526 Reviewed-by: https://github.com/trflynn89 ✅
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user