LibJS: Convert to_utf16_string() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-12 18:01:17 +01:00
commit da59c77fe3
Notes: sideshowbarker 2024-07-18 02:47:42 +09:00
5 changed files with 30 additions and 90 deletions

View file

@ -363,12 +363,12 @@ ThrowCompletionOr<String> Value::to_string(GlobalObject& global_object) const
}
}
Utf16String Value::to_utf16_string(GlobalObject& global_object) const
ThrowCompletionOr<Utf16String> Value::to_utf16_string(GlobalObject& global_object) const
{
if (m_type == Type::String)
return m_value.as_string->utf16_string();
auto utf8_string = TRY_OR_DISCARD(to_string(global_object));
auto utf8_string = TRY(to_string(global_object));
return Utf16String(utf8_string);
}