Add try-catch statements 52/239852/2
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Jul 2020 07:19:13 +0000 (16:19 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Jul 2020 08:28:56 +0000 (17:28 +0900)
Change-Id: I7b9570a89e70ace32d20ccd93326f368591f4560
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/tpk/tpk_backend.cc

index 4e0cc0319f7cc7174f65f7da3fd3188096d349ec..2da10bdd57907b898b6bc513450b39f810a68156 100644 (file)
@@ -29,20 +29,24 @@ int main(const int argc, char* argv[]) {
 
   ci::PkgmgrInstaller pkgmgr_installer;
   tpk::TpkAppQueryInterface interface;
-  ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(argc, argv,
-                                                     &pkgmgr_installer,
-                                                     &interface);
-  if (!pkgmgr) {
-    LOG(ERROR) << "Failed to create pkgmgr interface";
-    return -1;
-  }
+  try {
+    ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(argc, argv,
+                                                       &pkgmgr_installer,
+                                                       &interface);
+    if (!pkgmgr) {
+      LOG(ERROR) << "Failed to create pkgmgr interface";
+      return -1;
+    }
 
 #if __cplusplus >= 201300L
-  using std;
+    using std;
 #endif
-  ci::InstallerRunner runner(
-      make_unique<tpk::TpkInstallerFactory>(), pkgmgr);
-  ci::AppInstaller::Result result = runner.Run();
-
-  return (result == ci::AppInstaller::Result::OK) ? 0 : 1;
+    ci::InstallerRunner runner(
+        make_unique<tpk::TpkInstallerFactory>(), pkgmgr);
+    ci::AppInstaller::Result result = runner.Run();
+    return (result == ci::AppInstaller::Result::OK) ? 0 : 1;
+  } catch(...) {
+    LOG(ERROR) << "Exception occured";
+    return 1;
+  }
 }