diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index db041d3e8896a1..7ca4096e0ca70b 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -27,9 +27,7 @@ static Value get_promise_resolve(GlobalObject& global_object, Value constructor) VERIFY(constructor.is_constructor()); auto& vm = global_object.vm(); - auto promise_resolve = constructor.get(global_object, vm.names.resolve); - if (vm.exception()) - return {}; + auto promise_resolve = TRY_OR_DISCARD(constructor.get(global_object, vm.names.resolve)); if (!promise_resolve.is_function()) { vm.throw_exception(global_object, ErrorType::NotAFunction, promise_resolve.to_string_without_side_effects()); return {}; diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 873428de9708be..d19b9916bae7ca 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -733,16 +733,16 @@ ThrowCompletionOr Value::to_integer_or_infinity(GlobalObject& global_obj } // 7.3.3 GetV ( V, P ), https://tc39.es/ecma262/#sec-getv -Value Value::get(GlobalObject& global_object, PropertyName const& property_name) const +ThrowCompletionOr Value::get(GlobalObject& global_object, PropertyName const& property_name) const { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); // 2. Let O be ? ToObject(V). - auto* object = TRY_OR_DISCARD(to_object(global_object)); + auto* object = TRY(to_object(global_object)); // 3. Return ? O.[[Get]](P, V). - return TRY_OR_DISCARD(object->internal_get(property_name, *this)); + return TRY(object->internal_get(property_name, *this)); } // 7.3.10 GetMethod ( V, P ), https://tc39.es/ecma262/#sec-getmethod @@ -754,9 +754,7 @@ ThrowCompletionOr Value::get_method(GlobalObject& global_object VERIFY(property_name.is_valid()); // 2. Let func be ? GetV(V, P). - auto function = get(global_object, property_name); - if (auto* exception = vm.exception()) - return throw_completion(exception->value()); + auto function = TRY(get(global_object, property_name)); // 3. If func is either undefined or null, return undefined. if (function.is_nullish()) @@ -1485,9 +1483,7 @@ TriState is_less_than(GlobalObject& global_object, bool left_first, Value lhs, V ThrowCompletionOr Value::invoke_internal(GlobalObject& global_object, JS::PropertyName const& property_name, Optional arguments) { auto& vm = global_object.vm(); - auto property = get(global_object, property_name); - if (auto* exception = vm.exception()) - return throw_completion(exception->value()); + auto property = TRY(get(global_object, property_name)); if (!property.is_function()) return vm.throw_completion(global_object, ErrorType::NotAFunction, property.to_string_without_side_effects()); diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 99bcccdeae0d06..f0bac9cfcf5725 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -327,7 +327,7 @@ class Value { ThrowCompletionOr to_integer_or_infinity(GlobalObject&) const; bool to_boolean() const; - Value get(GlobalObject&, PropertyName const&) const; + ThrowCompletionOr get(GlobalObject&, PropertyName const&) const; ThrowCompletionOr get_method(GlobalObject&, PropertyName const&) const; String to_string_without_side_effects() const;