summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-20 21:16:30 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-21 09:02:23 +0100
commit5832de62fe5e2de4f9a65485246df6550aece33f (patch)
tree485f847a4dedebdcb2b11902bbe0256fa98518ed /Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
parent0881f8160fd81d8e25b7cc2eff2d64f2aed7ed53 (diff)
downloadserenity-5832de62fe5e2de4f9a65485246df6550aece33f.zip
LibJS: Convert NativeFunction::{call,construct}() to ThrowCompletionOr
Both at the same time because many of them call construct() in call() and I'm not keen on adding a bunch of temporary plumbing to turn exceptions into throw completions. Also changes the return value of construct() to Object* instead of Value as it always needs to return an object; allowing an arbitrary Value is a massive foot gun.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp b/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
index 319670ea26..ec6504beb0 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseJobs.cpp
@@ -26,7 +26,7 @@ PromiseReactionJob::PromiseReactionJob(PromiseReaction& reaction, Value argument
}
// 27.2.2.1 NewPromiseReactionJob ( reaction, argument ), https://tc39.es/ecma262/#sec-newpromisereactionjob
-Value PromiseReactionJob::call()
+ThrowCompletionOr<Value> PromiseReactionJob::call()
{
auto& vm = this->vm();
auto& promise_capability = m_reaction.capability();
@@ -64,11 +64,11 @@ Value PromiseReactionJob::call()
vm.stop_unwind();
auto* reject_function = promise_capability.value().reject;
dbgln_if(PROMISE_DEBUG, "[PromiseReactionJob @ {}]: Calling PromiseCapability's reject function @ {}", this, reject_function);
- return TRY_OR_DISCARD(vm.call(*reject_function, js_undefined(), handler_result));
+ return vm.call(*reject_function, js_undefined(), handler_result);
} else {
auto* resolve_function = promise_capability.value().resolve;
dbgln_if(PROMISE_DEBUG, "[PromiseReactionJob @ {}]: Calling PromiseCapability's resolve function @ {}", this, resolve_function);
- return TRY_OR_DISCARD(vm.call(*resolve_function, js_undefined(), handler_result));
+ return vm.call(*resolve_function, js_undefined(), handler_result);
}
}
@@ -94,7 +94,7 @@ PromiseResolveThenableJob::PromiseResolveThenableJob(Promise& promise_to_resolve
}
// 27.2.2.2 NewPromiseResolveThenableJob ( promiseToResolve, thenable, then ), https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob
-Value PromiseResolveThenableJob::call()
+ThrowCompletionOr<Value> PromiseResolveThenableJob::call()
{
auto& vm = this->vm();
auto [resolve_function, reject_function] = m_promise_to_resolve.create_resolving_functions();