[Iotcon] Some negative results excluded from throwing error 62/86062/3
authorTomasz Marciniak <t.marciniak@samsung.com>
Tue, 30 Aug 2016 09:34:48 +0000 (11:34 +0200)
committerJeongkyun Pu <jk.pu@samsung.com>
Tue, 6 Sep 2016 10:10:07 +0000 (03:10 -0700)
Change-Id: Ie2abb77c3e5df0166cf4ffbd456d1647ad3253b0
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/iotcon/iotcon_instance.cc
src/iotcon/iotcon_utils.cc

index 3572ca75d2fbce1ea52408ee731951bde32da1ea..057c7a554608c275ea6f559089d8ba2f0a898d9f 100644 (file)
@@ -286,9 +286,10 @@ common::TizenResult IotconInstance::ResourceAddResourceTypes(const picojson::obj
   const auto& types = IotconUtils::GetArg(args, kTypes).get<picojson::array>();
 
   for (const auto& type : types) {
-    result = IotconUtils::ConvertIotconError(iotcon_resource_bind_type(resource->handle, type.get<std::string>().c_str()));
-    if (!result) {
-      LogAndReturnTizenError(result, ("iotcon_resource_bind_type() failed"));
+    int ret = iotcon_resource_bind_type(resource->handle, type.get<std::string>().c_str());
+    if (IOTCON_ERROR_NONE != ret && IOTCON_ERROR_ALREADY != ret) {
+      LogAndReturnTizenError(
+          IotconUtils::ConvertIotconError(ret), ("iotcon_resource_bind_type() failed"));
     }
   }
 
@@ -309,9 +310,11 @@ common::TizenResult IotconInstance::ResourceAddResourceInterface(const picojson:
     LogAndReturnTizenError(result, ("GetResourceById() failed"));
   }
 
-  result = IotconUtils::ConvertIotconError(iotcon_resource_bind_interface(resource->handle, IotconUtils::GetArg(args, kInterface).get<std::string>().c_str()));
-  if (!result) {
-    LogAndReturnTizenError(result, ("iotcon_resource_bind_interface() failed"));
+  int ret = iotcon_resource_bind_interface(
+      resource->handle, IotconUtils::GetArg(args, kInterface).get<std::string>().c_str());
+  if (IOTCON_ERROR_NONE != ret && IOTCON_ERROR_ALREADY != ret) {
+    LogAndReturnTizenError(
+        IotconUtils::ConvertIotconError(ret), ("iotcon_resource_bind_interface() failed"));
   }
 
   return common::TizenSuccess();
@@ -339,9 +342,10 @@ common::TizenResult IotconInstance::ResourceAddChildResource(const picojson::obj
     LogAndReturnTizenError(result, ("GetResourceById() failed"));
   }
 
-  result = IotconUtils::ConvertIotconError(iotcon_resource_bind_child_resource(parent->handle, child->handle));
-  if (!result) {
-    LogAndReturnTizenError(result, ("iotcon_resource_bind_child_resource() failed"));
+  int ret = iotcon_resource_bind_child_resource(parent->handle, child->handle);
+  if (IOTCON_ERROR_NONE != ret && IOTCON_ERROR_ALREADY != ret) {
+    LogAndReturnTizenError(
+        IotconUtils::ConvertIotconError(ret), ("iotcon_resource_bind_child_resource() failed"));
   }
 
   parent->children.insert(child);
index 89e425c455276056be7840cde31be314ce25e934..39cb86618c2fde3396952abc0448e58cc8b2d0de 100644 (file)
@@ -1969,12 +1969,10 @@ common::TizenResult IotconUtils::ConvertIotconError(int error) {
     case IOTCON_ERROR_NOT_SUPPORTED:
       return common::NotSupportedError(error);
 
+    case IOTCON_ERROR_NO_DATA:
     case IOTCON_ERROR_INVALID_PARAMETER:
       return common::InvalidValuesError(error);
 
-    case IOTCON_ERROR_NO_DATA:
-      return common::NotFoundError(error);
-
     case IOTCON_ERROR_TIMEOUT:
       return common::TimeoutError(error);