wwbmmm commented on code in PR #1790:
URL: https://github.com/apache/incubator-brpc/pull/1790#discussion_r894130431


##########
src/brpc/policy/thrift_protocol.cpp:
##########
@@ -132,35 +132,38 @@ bool ReadThriftStruct(const butil::IOBuf& body,
             ::apache::thrift::transport::TMemoryBuffer::TAKE_OWNERSHIP);
     
apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TMemoryBuffer>
 iprot(in_buffer);
 
-    // The following code was taken from thrift auto generate code
-    std::string fname;
-
-    uint32_t xfer = 0;
-    ::apache::thrift::protocol::TType ftype;
-    int16_t fid;
-
-    xfer += iprot.readStructBegin(fname);
     bool success = false;
-    while (true) {
-        xfer += iprot.readFieldBegin(fname, ftype, fid);
-        if (ftype == ::apache::thrift::protocol::T_STOP) {
-            break;
-        }
-        if (fid == expected_fid) {
-            if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-                xfer += raw_msg->Read(&iprot);
-                success = true;
+    try {
+        // The following code was taken from thrift auto generate code
+        std::string fname;
+
+        uint32_t xfer = 0;
+        ::apache::thrift::protocol::TType ftype;
+        int16_t fid;
+        xfer += iprot.readStructBegin(fname);
+        while (true) {
+            xfer += iprot.readFieldBegin(fname, ftype, fid);
+            if (ftype == ::apache::thrift::protocol::T_STOP) {
+                break;
+            }
+            if (fid == expected_fid) {
+                if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+                    xfer += raw_msg->Read(&iprot);
+                    success = true;
+                } else {
+                    xfer += iprot.skip(ftype);
+                }
             } else {
                 xfer += iprot.skip(ftype);
             }
-        } else {
-            xfer += iprot.skip(ftype);
+            xfer += iprot.readFieldEnd();
         }
-        xfer += iprot.readFieldEnd();
-    }
 
-    xfer += iprot.readStructEnd();
-    iprot.getTransport()->readEnd();
+        xfer += iprot.readStructEnd();
+        iprot.getTransport()->readEnd();
+    } catch (...) {

Review Comment:
   如果已知具体的exception类型,可以声明一下,并且打exception的信息打印出来,这样更方便定位问题



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to