1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibJS: Convert to_utf16_string() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-12 18:01:17 +01:00
parent 4d8912a92b
commit da59c77fe3
5 changed files with 30 additions and 90 deletions

View file

@ -883,11 +883,7 @@ Value canonical_numeric_index_string(GlobalObject& global_object, PropertyName c
// 22.1.3.17.1 GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ), https://tc39.es/ecma262/#sec-getsubstitution
ThrowCompletionOr<String> get_substitution(GlobalObject& global_object, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement)
{
auto& vm = global_object.vm();
auto replace_string = replacement.to_utf16_string(global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
auto replace_string = TRY(replacement.to_utf16_string(global_object));
auto replace_view = replace_string.view();
StringBuilder result;