return value;
}
+tl::expected<std::string, Client::Error>
+Client::receive_error_string()
+{
+ TRY_ASSIGN(uint8_t msg_len, receive_u8());
+ TRY_ASSIGN(auto msg_bytes, receive_bytes(msg_len));
+ return std::string(msg_bytes.begin(), msg_bytes.end());
+}
+
tl::expected<std::optional<util::Bytes>, Client::Error>
Client::receive_response_get()
{
return std::nullopt;
case Status::error: {
- TRY_ASSIGN(uint8_t msg_len, receive_u8());
- TRY_ASSIGN(auto msg_bytes, receive_bytes(msg_len));
- std::string error_msg(msg_bytes.begin(), msg_bytes.end());
- return tl::unexpected(Error(Failure::error, error_msg));
+ TRY_ASSIGN(auto err_msg, receive_error_string());
+ return tl::unexpected(Error(Failure::error, err_msg));
}
default:
return false;
case Status::error: {
- TRY_ASSIGN(uint8_t msg_len, receive_u8());
- TRY_ASSIGN(auto msg_bytes, receive_bytes(msg_len));
- std::string error_msg(msg_bytes.begin(), msg_bytes.end());
- return tl::unexpected(Error(Failure::error, error_msg));
+ TRY_ASSIGN(auto err_msg, receive_error_string());
+ return tl::unexpected(Error(Failure::error, err_msg));
}
default:
return {};
case Status::error: {
- TRY_ASSIGN(uint8_t msg_len, receive_u8());
- TRY_ASSIGN(auto msg_bytes, receive_bytes(msg_len));
- std::string error_msg(msg_bytes.begin(), msg_bytes.end());
- return tl::unexpected(Error(Failure::error, error_msg));
+ TRY_ASSIGN(auto err_msg, receive_error_string());
+ return tl::unexpected(Error(Failure::error, err_msg));
}
default:
tl::expected<util::Bytes, Error> receive_bytes(size_t count);
tl::expected<uint8_t, Error> receive_u8();
tl::expected<uint64_t, Error> receive_u64();
+ tl::expected<std::string, Error> receive_error_string();
tl::expected<std::optional<util::Bytes>, Error> receive_response_get();
tl::expected<bool, Error> receive_response_bool();
tl::expected<void, Error> receive_response_void();