mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
LibJS: Convert to_number() to ThrowCompletionOr
This commit is contained in:
parent
a36ee213b9
commit
20d990563c
Notes:
sideshowbarker
2024-07-18 02:12:47 +09:00
Author: https://github.com/IdanHo
Commit: 20d990563c
Pull-request: https://github.com/SerenityOS/serenity/pull/10522
Reviewed-by: https://github.com/linusg ✅
22 changed files with 149 additions and 343 deletions
|
@ -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 {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue