1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:57:36 +00:00

AK+Userland: Make AK::decode_hex() return ErrorOr

This lets us propagate the reason why it failed up to the caller. :^)
This commit is contained in:
Sam Atkins 2022-01-20 17:01:39 +00:00 committed by Andreas Kling
parent 45cf40653a
commit f590cd1850
6 changed files with 31 additions and 33 deletions

View file

@ -39,8 +39,12 @@ Optional<ByteBuffer> Filter::decode(ReadonlyBytes bytes, FlyString const& encodi
Optional<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes bytes)
{
if (bytes.size() % 2 == 0)
return decode_hex(bytes);
if (bytes.size() % 2 == 0) {
auto decode_result = decode_hex(bytes);
if (decode_result.is_error())
return {};
return decode_result.release_value();
}
// FIXME: Integrate this padding into AK/Hex?