1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

LibJS: Convert to_number() to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-17 23:20:05 +03:00
parent a36ee213b9
commit 20d990563c
22 changed files with 149 additions and 343 deletions

View file

@ -122,9 +122,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_code_point)
string.ensure_capacity(vm.argument_count()); // This will be an under-estimate if any code point is > 0xffff.
for (size_t i = 0; i < vm.argument_count(); ++i) {
auto next_code_point = vm.argument(i).to_number(global_object);
if (vm.exception())
return {};
auto next_code_point = TRY_OR_DISCARD(vm.argument(i).to_number(global_object));
if (!next_code_point.is_integral_number()) {
vm.throw_exception<RangeError>(global_object, ErrorType::InvalidCodePoint, next_code_point.to_string_without_side_effects());
return {};