From da74407021b1d1868d91b7f9dd3973246e698251 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Tue, 30 Aug 2016 11:34:48 +0200 Subject: [PATCH] [Iotcon] Some negative results excluded from throwing error Change-Id: Ie2abb77c3e5df0166cf4ffbd456d1647ad3253b0 Signed-off-by: Tomasz Marciniak --- src/iotcon/iotcon_instance.cc | 22 +++++++++++++--------- src/iotcon/iotcon_utils.cc | 4 +--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/iotcon/iotcon_instance.cc b/src/iotcon/iotcon_instance.cc index 3572ca75..057c7a55 100644 --- a/src/iotcon/iotcon_instance.cc +++ b/src/iotcon/iotcon_instance.cc @@ -286,9 +286,10 @@ common::TizenResult IotconInstance::ResourceAddResourceTypes(const picojson::obj const auto& types = IotconUtils::GetArg(args, kTypes).get(); for (const auto& type : types) { - result = IotconUtils::ConvertIotconError(iotcon_resource_bind_type(resource->handle, type.get().c_str())); - if (!result) { - LogAndReturnTizenError(result, ("iotcon_resource_bind_type() failed")); + int ret = iotcon_resource_bind_type(resource->handle, type.get().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().c_str())); - if (!result) { - LogAndReturnTizenError(result, ("iotcon_resource_bind_interface() failed")); + int ret = iotcon_resource_bind_interface( + resource->handle, IotconUtils::GetArg(args, kInterface).get().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); diff --git a/src/iotcon/iotcon_utils.cc b/src/iotcon/iotcon_utils.cc index 89e425c4..39cb8661 100644 --- a/src/iotcon/iotcon_utils.cc +++ b/src/iotcon/iotcon_utils.cc @@ -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); -- 2.34.1