From: Hwankyu Jhun Date: Fri, 12 Aug 2022 01:04:35 +0000 (+0900) Subject: Fix wrong exception handling X-Git-Tag: accepted/tizen/unified/20220817.153847~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b0c4894604883067240417d4549a3cdfae58d9b;p=platform%2Fcore%2Fappfw%2Faul-1.git Fix wrong exception handling If the AppRequest() is not used to send the request, the result value has to be converted using the aul_error_convert(). While creating the LocalizedInfo instance if the locale is empty, we throw the exception. The previous implementation, AUL only checks whether the locale is empty or not. Change-Id: I6c25e1e9c415d6dc3e3be18862f34c88da2df980 Signed-off-by: Hwankyu Jhun --- diff --git a/aul/component/localized_info.cc b/aul/component/localized_info.cc index 99ede26..0c0f488 100644 --- a/aul/component/localized_info.cc +++ b/aul/component/localized_info.cc @@ -46,9 +46,7 @@ LocalizedInfo::Builder::operator LocalizedInfo*() { } void LocalizedInfo::Builder::Validate() { - if (locale_.empty() || - icon_.empty() || - label_.empty()) + if (locale_.empty()) THROW(AUL_R_ERROR); } diff --git a/src/aul_comp_context.cc b/src/aul_comp_context.cc index ef2298f..b93e82c 100644 --- a/src/aul_comp_context.cc +++ b/src/aul_comp_context.cc @@ -59,7 +59,7 @@ ComponentRunningContext* GetComponentRunningContext( .With(std::move(b)) .SendSimply(AUL_SOCK_ASYNC); if (fd < 0) - THROW(aul_error_convert(fd)); + THROW(fd); app_pkt_t* pkt; int ret = aul_sock_recv_reply_pkt(fd, &pkt); @@ -92,7 +92,7 @@ GetComponentRunningContexts() { int fd = AppRequest(COMP_CONTEXT_FOREACH, getuid()) .SendSimply(AUL_SOCK_ASYNC); if (fd < 0) - THROW(aul_error_convert(fd)); + THROW(fd); std::vector> contexts; int ret = aul_sock_recv_pkt_with_cb(fd, @@ -141,7 +141,7 @@ int SendRequest(ComponentRunningContext* context, int cmd) { .With(std::move(b)) .SendSimply(); if (ret < 0) - THROW(aul_error_convert(ret)); + THROW(ret); return ret; } diff --git a/src/aul_comp_info.cc b/src/aul_comp_info.cc index 36204ed..544579f 100644 --- a/src/aul_comp_info.cc +++ b/src/aul_comp_info.cc @@ -64,7 +64,7 @@ std::string GetSystemLocale() { ComponentInfo* CreateComponentInfoFromAppPacket( app_pkt_t* pkt) { if (pkt->cmd != APP_GET_INFO_OK) - THROW(pkt->cmd); + THROW(aul_error_convert(pkt->cmd)); bundle* kb = nullptr; if (pkt->opt & AUL_SOCK_BUNDLE) { @@ -99,7 +99,7 @@ ComponentInfo* GetComponentInfo(const char* comp_id, app_pkt_t* pkt = nullptr; int ret = aul_sock_recv_reply_pkt(fd, &pkt); if (ret < 0) - THROW(ret); + THROW(aul_error_convert(ret)); auto pkt_auto = std::unique_ptr( pkt, std::free); @@ -128,7 +128,7 @@ std::vector> GetComponentInfos(uid_t uid) { } }, &component_infos); if (ret < 0) - THROW(ret); + THROW(aul_error_convert(ret)); return component_infos; } @@ -281,8 +281,11 @@ extern "C" API int aul_comp_info_get_icon(aul_comp_info_h handle, auto* info = static_cast(handle); try { auto* localized_info = info->GetLocalizedInfo(GetSystemLocale()); - if (localized_info == nullptr) - return AUL_R_ENOENT; + if (localized_info == nullptr) { + localized_info = info->GetLocalizedInfo(kDefaultLocale); + if (localized_info == nullptr) + return AUL_R_ENOENT; + } *icon = localized_info->GetIcon().c_str(); } catch (const Exception& e) { @@ -303,8 +306,11 @@ extern "C" API int aul_comp_info_get_label(aul_comp_info_h handle, auto* info = static_cast(handle); try { auto* localized_info = info->GetLocalizedInfo(GetSystemLocale()); - if (localized_info == nullptr) - return AUL_R_ENOENT; + if (localized_info == nullptr) { + localized_info = info->GetLocalizedInfo(kDefaultLocale); + if (localized_info == nullptr) + return AUL_R_ENOENT; + } *label = localized_info->GetLabel().c_str(); } catch (const Exception& e) { @@ -324,8 +330,11 @@ extern "C" API int aul_comp_info_get_localed_label(aul_comp_info_h handle, auto* info = static_cast(handle); auto* localized_info = info->GetLocalizedInfo(locale); - if (localized_info == nullptr) - return AUL_R_ENOENT; + if (localized_info == nullptr) { + localized_info = info->GetLocalizedInfo(kDefaultLocale); + if (localized_info == nullptr) + return AUL_R_ENOENT; + } *label = localized_info->GetLabel().c_str(); return AUL_R_OK;