From 44a2a2fcab63071375841d7a5001dd301ebac194 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Thu, 21 Jun 2018 13:05:27 -0400 Subject: json: include field name in InvalidName status messages. This is invaluable for chasing down the culprit in failed JSON -> proto conversions. We often see in Envoy that a failed JSON (or indirectly via YAML) configuration won't load but it's unclear why. Signed-off-by: Harvey Tuch --- src/google/protobuf/util/json_util.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index f81a7a30..dd8c6111 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -127,7 +127,8 @@ class StatusErrorListener : public converter::ErrorListener { virtual void InvalidName(const converter::LocationTrackerInterface& loc, StringPiece unknown_name, StringPiece message) { status_ = util::Status(util::error::INVALID_ARGUMENT, - loc.ToString() + ": " + string(message)); + loc.ToString() + ":invalid name " + + string(unknown_name) + ": " + string(message)); } virtual void InvalidValue(const converter::LocationTrackerInterface& loc, -- cgit v1.2.3 From 6eb78b1e845620a56990b415fdf50a25594ea445 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Thu, 21 Jun 2018 14:09:53 -0400 Subject: Additional whitespace. Signed-off-by: Harvey Tuch --- src/google/protobuf/util/json_util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index dd8c6111..9ad073d8 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -127,7 +127,7 @@ class StatusErrorListener : public converter::ErrorListener { virtual void InvalidName(const converter::LocationTrackerInterface& loc, StringPiece unknown_name, StringPiece message) { status_ = util::Status(util::error::INVALID_ARGUMENT, - loc.ToString() + ":invalid name " + + loc.ToString() + ": invalid name " + string(unknown_name) + ": " + string(message)); } -- cgit v1.2.3