mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibJS+Everywhere: Convert JS::Error to String
This includes an Error::create overload to create an Error from a UTF-8 StringView. If creating a String from that view fails, the factory will return an OOM InternalError instead. VM::throw_completion can also make use of this overload via its perfect forwarding.
This commit is contained in:
parent
153b793638
commit
88814acbd3
Notes:
sideshowbarker
2024-07-17 02:38:39 +09:00
Author: https://github.com/trflynn89
Commit: 88814acbd3
Pull-request: https://github.com/SerenityOS/serenity/pull/17494
Reviewed-by: https://github.com/linusg ✅
36 changed files with 198 additions and 151 deletions
|
@ -71,7 +71,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
|
|||
// 6. Set resolve.[[AlreadyResolved]] to alreadyResolved.
|
||||
|
||||
// 27.2.1.3.2 Promise Resolve Functions, https://tc39.es/ecma262/#sec-promise-resolve-functions
|
||||
auto resolve_function = PromiseResolvingFunction::create(realm, *this, *already_resolved, [](auto& vm, auto& promise, auto& already_resolved) {
|
||||
auto resolve_function = PromiseResolvingFunction::create(realm, *this, *already_resolved, [](auto& vm, auto& promise, auto& already_resolved) -> ThrowCompletionOr<Value> {
|
||||
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / PromiseResolvingFunction]: Resolve function was called", &promise);
|
||||
|
||||
auto& realm = *vm.current_realm();
|
||||
|
@ -97,7 +97,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
|
|||
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / PromiseResolvingFunction]: Promise can't be resolved with itself, rejecting with error", &promise);
|
||||
|
||||
// a. Let selfResolutionError be a newly created TypeError object.
|
||||
auto self_resolution_error = TypeError::create(realm, "Cannot resolve promise with itself");
|
||||
auto self_resolution_error = MUST_OR_THROW_OOM(TypeError::create(realm, "Cannot resolve promise with itself"sv));
|
||||
|
||||
// b. Perform RejectPromise(promise, selfResolutionError).
|
||||
promise.reject(self_resolution_error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue