Add an exception handling 87/188687/5
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 7 Sep 2018 09:16:52 +0000 (18:16 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Sun, 9 Sep 2018 23:56:40 +0000 (08:56 +0900)
Cpp Generator:
 - Adds an exception handling about rpc_port_parcel_send()

C Generator:
 - Sets the result of rpc_port_parcel_send()

Change-Id: I6ec3a0028ba1c83e50735717a97a1009d350939b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/c_gen/c_proxy_body_gen.cc
idlc/c_gen/c_proxy_body_gen_cb.h
idlc/cpp_gen/cpp_proxy_body_gen_cb.h

index 0f9bdea..11aae75 100644 (file)
@@ -450,8 +450,10 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
                                                const Declaration& decl) {
   const char setter[] = "$$($$, $$);\n";
   std::string str;
-  if (decl.GetMethodType() != Declaration::MethodType::SYNC)
+  if (decl.GetMethodType() != Declaration::MethodType::SYNC) {
+    str += "set_last_result(r);" + NLine(1);
     return str;
+  }
   str += GenTemplateString(CB_RECEIVE_BLOCK,
       [&]()->std::string {
         std::string s;
@@ -523,6 +525,7 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
           return s;
         });
   if (GetReturnTypeString(decl.GetType()) != "void ") {
+    str += "set_last_result(r);" + NLine(1);
     str += NLine(1);
     str += "return ret;";
   }
index 2499fa7..cd22b33 100644 (file)
@@ -273,6 +273,7 @@ R"__c_cb(
 $$rpc_port_proxy_##_invoke_$$(rpc_port_proxy_##_h h$$)
 {
     rpc_port_parcel_h parcel;
+    int r;
 $$
 
     if (!h$$) {
@@ -288,7 +289,12 @@ $$
     rpc_port_parcel_create(&parcel);
     rpc_port_parcel_write_int32(parcel, ##_METHOD_$$);
 $$
-    rpc_port_parcel_send(parcel, h->port);
+    r = rpc_port_parcel_send(parcel, h->port);
+    if (r != RPC_PORT_ERROR_NONE) {
+        _E("Failed to send parcel. result(%d)", r);
+        r = RPC_PORT_ERROR_IO_ERROR;
+    }
+
     rpc_port_parcel_destroy(parcel);
 $$
 }
index 35347e3..b5dbefd 100644 (file)
@@ -38,7 +38,12 @@ R"__cpp_cb(  if (port_ == nullptr) {
 const char CB_INVOCATION_MID[] =
 R"__cpp_cb(
     // Send
-    rpc_port_parcel_send(p, port_);
+    int r = rpc_port_parcel_send(p, port_);
+    if (r != RPC_PORT_ERROR_NONE) {
+      _E("Failed to send parcel. result(%d)", r);
+      rpc_port_parcel_destroy(p);
+      throw InvalidIOException();
+    }
 )__cpp_cb";
 
 const char CB_INVOCATION_RECEIVE[] =