Fixes txn delete response to keep backwards compatibility (#239)

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
This commit is contained in:
Tao He 2023-07-17 10:43:19 +08:00 committed by GitHub
parent 2c0d824ebe
commit 3d344190d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -212,15 +212,21 @@ void etcdv3::AsyncTxnResponse::ParseResponse(TxnResponse& reply) {
AsyncDeleteResponse response;
response.ParseResponse(*(resp.mutable_response_delete_range()));
if (error_code == 0) {
// Ignore "key not found" error for delete in txn, keep backwards
// compatibility.
if (response.get_error_code() != 0 &&
response.get_error_code() != etcdv3::ERROR_KEY_NOT_FOUND) {
error_code = response.get_error_code();
}
if (!response.get_error_message().empty()) {
if (response.get_error_code() != 0 &&
response.get_error_code() != etcdv3::ERROR_KEY_NOT_FOUND) {
if (!error_message.empty()) {
error_message += "\n";
}
error_message += response.get_error_message();
}
}
for (auto const& value : response.get_values()) {
values.emplace_back(value);
}