mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-31 15:32:51 +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
|
@ -158,9 +158,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamDefaultReader::
|
|||
|
||||
// 1. If this.[[stream]] is undefined, return a promise rejected with a TypeError exception.
|
||||
if (!m_stream) {
|
||||
auto exception = JS::TypeError::create(realm, "Cannot read from an empty stream"sv);
|
||||
auto promise_capability = WebIDL::create_rejected_promise(realm, exception);
|
||||
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise_capability->promise()) };
|
||||
WebIDL::SimpleException exception { WebIDL::SimpleExceptionType::TypeError, "Cannot read from an empty stream"sv };
|
||||
return WebIDL::create_rejected_promise_from_exception(realm, move(exception));
|
||||
}
|
||||
|
||||
// 2. Let promise be a new promise.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue