LibUnicode: Propagate try_append() errors when building emoji data

This commit is contained in:
MacDue 2023-02-24 21:07:09 +00:00 committed by Linus Groh
parent f064f5f36e
commit 01fa3bb788
Notes: sideshowbarker 2024-07-17 11:34:34 +09:00

View file

@ -140,20 +140,21 @@ static ErrorOr<void> parse_emoji_serenity_data(Core::BufferedFile& file, EmojiDa
emoji.group = Unicode::EmojiGroup::SerenityOS;
emoji.display_order = display_order++;
line.for_each_split_view(' ', SplitBehavior::Nothing, [&](auto segment) {
TRY(line.for_each_split_view(' ', SplitBehavior::Nothing, [&](auto segment) -> ErrorOr<void> {
if (segment.starts_with(code_point_header)) {
segment = segment.substring_view(code_point_header.length());
auto code_point = AK::StringUtils::convert_to_uint_from_hex<u32>(segment);
VERIFY(code_point.has_value());
emoji.code_points.append(*code_point);
TRY(emoji.code_points.try_append(*code_point));
} else {
if (!builder.is_empty())
builder.append(' ');
builder.append(segment);
TRY(builder.try_append(' '));
TRY(builder.try_append(segment));
}
});
return {};
}));
auto name = builder.to_deprecated_string();
if (!any_of(name, is_ascii_lower_alpha))