From: Tomasz Marciniak Date: Tue, 30 Aug 2016 09:34:48 +0000 (+0200) Subject: [Iotcon] Some negative results excluded from throwing error X-Git-Tag: submit/tizen/20160907.005039~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F86062%2F3;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Iotcon] Some negative results excluded from throwing error Change-Id: Ie2abb77c3e5df0166cf4ffbd456d1647ad3253b0 Signed-off-by: Tomasz Marciniak --- 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);