LibWeb/Streams: Use MUST_OR_THROW_OOM() when creating JS exceptions

This cannot throw unless we OOM.
This commit is contained in:
Linus Groh 2023-04-14 15:52:11 +02:00
commit 1c165b67ef
Notes: sideshowbarker 2024-07-16 21:39:23 +09:00
4 changed files with 7 additions and 5 deletions

View file

@ -27,7 +27,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> ReadableStreamGenericReaderMi
// 1. If this.[[stream]] is undefined, return a promise rejected with a TypeError exception.
if (!m_stream) {
auto& realm = stream()->realm();
auto promise_capability = WebIDL::create_rejected_promise(realm, TRY(JS::TypeError::create(realm, "No stream present to cancel"sv)));
auto exception = MUST_OR_THROW_OOM(JS::TypeError::create(realm, "No stream present to cancel"sv));
auto promise_capability = WebIDL::create_rejected_promise(realm, exception);
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise_capability->promise().ptr()) };
}