aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Kosiński <krzysio@google.com>2024-03-15 23:24:46 +0000
committerKrzysztof Kosiński <krzysio@google.com>2024-03-15 23:24:46 +0000
commit8e8906f6945c022de9056bc6c84bbf2294261074 (patch)
treebe1bc4ce19b3fe5307aa9003d517a99b91473fa2
parente8cea65741e47490bed5987aeb9d26fb25118821 (diff)
downloaddittosuite-8e8906f6945c022de9056bc6c84bbf2294261074.tar.gz
Fix incompatibility with Protobuf 22.x.
In version 22.x, the JSON conversion functions return absl::Status, which is marked nodiscard. Check the ok() function before printing the output. Bug: 329747255 Test: presubmit Change-Id: I46e2f20a26953dc6501f51daecc1a56547a326ab
-rw-r--r--src/result.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/result.cpp b/src/result.cpp
index 0726d34..e0b82a6 100644
--- a/src/result.cpp
+++ b/src/result.cpp
@@ -416,10 +416,11 @@ void PrintPb(const dittosuiteproto::Result &pb) {
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
- google::protobuf::util::MessageToJsonString(pb, &json, options);
-
- std::ostream pb_stream(std::cout.rdbuf());
- pb_stream << json << std::endl;
+ auto status = google::protobuf::util::MessageToJsonString(pb, &json, options);
+ if (status.ok()) {
+ std::ostream pb_stream(std::cout.rdbuf());
+ pb_stream << json << std::endl;
+ }
}
std::unique_ptr<Result> Result::FromPb(const dittosuiteproto::Result& pb) {