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

AK: Make ByteBuffer::try_* functions return ErrorOr<void>

Same as Vector, ByteBuffer now also signals allocation failure by
returning an ENOMEM Error instead of a bool, allowing us to use the
TRY() and MUST() patterns.
This commit is contained in:
Andreas Kling 2021-11-10 14:33:44 +01:00
parent 88b6428c25
commit a15ed8743d
20 changed files with 59 additions and 70 deletions

View file

@ -57,8 +57,8 @@ String InspectableProcess::wait_for_response()
auto packet = m_socket->read(remaining_bytes);
if (packet.size() == 0)
break;
if (!data.try_append(packet.data(), packet.size())) {
dbgln("Failed to append {} bytes to data buffer", packet.size());
if (auto result = data.try_append(packet.data(), packet.size()); result.is_error()) {
dbgln("Failed to append {} bytes to data buffer: {}", packet.size(), result.error());
break;
}
remaining_bytes -= packet.size();