summaryrefslogtreecommitdiff
path: root/Userland/Libraries
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
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')
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Body.cpp3
-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
4 files changed, 7 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Body.cpp b/Userland/Libraries/LibWeb/Fetch/Body.cpp
index f9b87e06b7..65046ce99a 100644
--- a/Userland/Libraries/LibWeb/Fetch/Body.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Body.cpp
@@ -148,7 +148,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> consume_body(JS::Realm& realm
{
// 1. If object is unusable, then return a promise rejected with a TypeError.
if (object.is_unusable()) {
- auto promise_capability = WebIDL::create_rejected_promise(realm, JS::TypeError::create(realm, "Body is unusable"sv).release_allocated_value_but_fixme_should_propagate_errors());
+ auto exception = MUST_OR_THROW_OOM(JS::TypeError::create(realm, "Body is unusable"sv));
+ auto promise_capability = WebIDL::create_rejected_promise(realm, exception);
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise_capability->promise().ptr()) };
}
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()) };
}