diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index 32a5768e9f..4b2280c956 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -81,27 +81,27 @@ static Value get_value_from_constructor_argument(GlobalObject& global_object) } // 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value -Value NumberConstructor::call() +ThrowCompletionOr<Value> NumberConstructor::call() { auto& vm = this->vm(); auto& global_object = this->global_object(); auto number = get_value_from_constructor_argument(global_object); - if (vm.exception()) - return {}; + if (auto* exception = vm.exception()) + return throw_completion(exception->value()); return number; } // 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value -Value NumberConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); auto number = get_value_from_constructor_argument(global_object); - if (vm.exception()) - return {}; - return TRY_OR_DISCARD(ordinary_create_from_constructor<NumberObject>(global_object, new_target, &GlobalObject::number_prototype, number.as_double())); + if (auto* exception = vm.exception()) + return throw_completion(exception->value()); + return TRY(ordinary_create_from_constructor<NumberObject>(global_object, new_target, &GlobalObject::number_prototype, number.as_double())); } // 21.1.2.2 Number.isFinite ( number ), https://tc39.es/ecma262/#sec-number.isfinite |