summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Streams
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2023-04-14 15:52:11 +0200
committerLinus Groh <mail@linusgroh.de>2023-04-14 16:35:17 +0200
commit1c165b67efb3c4b13a603b668269d8a15d224246 (patch)
treed21a2133f028c806b22387365d3d5e965567f798 /Userland/Libraries/LibWeb/Streams
parentd192f4452375e9d34a9a078a302be66104091b88 (diff)
downloadserenity-1c165b67efb3c4b13a603b668269d8a15d224246.zip
LibWeb/Streams: Use MUST_OR_THROW_OOM() when creating JS exceptions
This cannot throw unless we OOM.
Diffstat (limited to 'Userland/Libraries/LibWeb/Streams')
-rw-r--r--Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableStreamGenericReader.cpp3
3 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
index f9c73773e0..309a038350 100644
--- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
+++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
@@ -308,7 +308,7 @@ WebIDL::ExceptionOr<void> readable_stream_reader_generic_release(ReadableStreamG
auto& realm = stream->realm();
// 4. If stream.[[state]] is "readable", reject reader.[[closedPromise]] with a TypeError exception.
- auto exception = TRY(JS::TypeError::create(realm, "Released readable stream"sv));
+ auto exception = MUST_OR_THROW_OOM(JS::TypeError::create(realm, "Released readable stream"sv));
if (stream->is_readable()) {
WebIDL::reject_promise(realm, *reader.closed_promise_capability(), exception);
}
@@ -389,7 +389,7 @@ WebIDL::ExceptionOr<void> readable_stream_default_reader_release(ReadableStreamD
TRY(readable_stream_reader_generic_release(reader));
// 2. Let e be a new TypeError exception.
- auto e = TRY(JS::TypeError::create(realm, "Reader has been released"sv));
+ auto e = MUST_OR_THROW_OOM(JS::TypeError::create(realm, "Reader has been released"sv));
// 3. Perform ! ReadableStreamDefaultReaderErrorReadRequests(reader, e).
readable_stream_default_reader_error_read_requests(reader, e);
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp
index c0124bef08..fed654546f 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp
@@ -84,7 +84,7 @@ 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 = TRY(JS::TypeError::create(realm, "Cannot read from an empty stream"sv));
+ auto exception = MUST_OR_THROW_OOM(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()) };
}
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamGenericReader.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStreamGenericReader.cpp
index be7eb391ca..3679f85dc2 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamGenericReader.cpp
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamGenericReader.cpp
@@ -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()) };
}