mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [3/4] mesos git commit: Fixed protobuf::parse to surface nested message parsing errors.
Date Tue, 12 Jan 2016 01:21:48 GMT
Fixed protobuf::parse to surface nested message parsing errors.

Previously, errors parsing nested messages were ignored.

Review: https://reviews.apache.org/r/42167/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d291930d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d291930d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d291930d

Branch: refs/heads/master
Commit: d291930d93c5e679c698ee7a8480e244afcea16d
Parents: bb61e14
Author: Gilbert Song <songzihao1990@gmail.com>
Authored: Mon Jan 11 16:54:40 2016 -0800
Committer: Benjamin Mahler <benjamin.mahler@gmail.com>
Committed: Mon Jan 11 17:21:36 2016 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/protobuf.hpp    | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d291930d/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
index adb68c3..22cb5d9 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
@@ -332,10 +332,25 @@ struct Parser : boost::static_visitor<Try<Nothing> >
   {
     switch (field->type()) {
       case google::protobuf::FieldDescriptor::TYPE_MESSAGE:
+        // TODO(gilbert): We currently push up the nested error
+        // messages without wrapping the error message (due to
+        // the recursive nature of parse). We should pass along
+        // variable information in order to construct a helpful
+        // error message, e.g. "Failed to parse field 'a.b.c': ...".
         if (field->is_repeated()) {
-          parse(reflection->AddMessage(message, field), object);
+          Try<Nothing> parse =
+            internal::parse(reflection->AddMessage(message, field), object);
+
+          if (parse.isError()) {
+            return parse;
+          }
         } else {
-          parse(reflection->MutableMessage(message, field), object);
+          Try<Nothing> parse =
+            internal::parse(reflection->MutableMessage(message, field), object);
+
+          if (parse.isError()) {
+            return parse;
+          }
         }
         break;
       default:


Mime
View raw message