mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15: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:
parent
45cf40653a
commit
f590cd1850
6 changed files with 31 additions and 33 deletions
|
@ -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?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue