Add exception handling 85/242185/3
authorChanggyu Choi <changyu.choi@samsung.com>
Tue, 25 Aug 2020 00:22:16 +0000 (09:22 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 25 Aug 2020 00:24:37 +0000 (09:24 +0900)
Change-Id: I4f8e53fe51f698708a0ddc59e814c1ff7801d587
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
parser/metadata/alias-appid/plugin_manager.cc
parser/metadata/allowed-appid/plugin_manager.cc

index 44e13df..c057d5a 100644 (file)
@@ -35,11 +35,11 @@ PluginManager& PluginManager::GetInst() {
 
 bool PluginManager::StepInstall(const std::unique_ptr<AppEventArgs>& args) {
   auto* db = dynamic_cast<AppSvcDB*>(GetDB());
-
   if (db == nullptr) {
     _E("MetadataPlugin is not prepared");
     return false;
   }
+
   for (auto& metadata : args->GetMetadataList()) {
     try {
       db->Insert(metadata->GetValue(), args->GetAppId());
@@ -52,11 +52,11 @@ bool PluginManager::StepInstall(const std::unique_ptr<AppEventArgs>& args) {
 
 bool PluginManager::StepUninstall(const std::unique_ptr<AppEventArgs>& args) {
   auto* db = dynamic_cast<AppSvcDB*>(GetDB());
-
   if (db == nullptr) {
     _E("MetadataPlugin is not prepared");
     return false;
   }
+
   if (args->GetMetadataList().empty()) {
     try {
       db->Delete(args->GetAppId());
@@ -78,11 +78,11 @@ bool PluginManager::StepUninstall(const std::unique_ptr<AppEventArgs>& args) {
 
 bool PluginManager::StepUpgrade(const std::unique_ptr<AppEventArgs>& args) {
   auto* db = dynamic_cast<AppSvcDB*>(GetDB());
-
   if (db == nullptr) {
     _E("MetadataPlugin is not prepared");
     return false;
   }
+
   try {
     db->Delete(args->GetAppId());
   } catch (Exception& e) {
index 6f50a7e..d6de6c8 100644 (file)
@@ -35,6 +35,11 @@ PluginManager& PluginManager::GetInst() {
 
 bool PluginManager::StepInstall(const std::unique_ptr<AppEventArgs>& args) {
   auto* db = dynamic_cast<AppSvcDB*>(GetDB());
+  if (db == nullptr) {
+    _E("MetadataPlugin is not prepared");
+    return false;
+  }
+
   for (auto& metadata : args->GetMetadataList()) {
     try {
       db->Insert(args->GetAppId(), metadata->GetValue());
@@ -46,8 +51,13 @@ bool PluginManager::StepInstall(const std::unique_ptr<AppEventArgs>& args) {
 }
 
 bool PluginManager::StepUninstall(const std::unique_ptr<AppEventArgs>& args) {
+  auto* db = dynamic_cast<AppSvcDB*>(GetDB());
+  if (db == nullptr) {
+    _E("MetadataPlugin is not prepared");
+    return false;
+  }
+
   try {
-    auto* db = dynamic_cast<AppSvcDB*>(GetDB());
     db->Delete(args->GetAppId());
   } catch (Exception& e) {
     _W("Failed to delete alias info. appid(%s)", args->GetAppId().c_str());