Add try-catch statements 51/239851/2
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Jul 2020 07:18:54 +0000 (16:18 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Jul 2020 08:29:51 +0000 (17:29 +0900)
Change-Id: Ib83a73359ab768f2af0e5bbf7e5eac52446a3ba3
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/wgt_backend/wgt_backend.cc

index c72e135..3286b08 100644 (file)
@@ -29,27 +29,33 @@ std::unique_ptr<T> make_unique(Args&&... args) {
 int main(int argc, char** argv) {
   ci::PkgmgrInstaller pkgmgr_installer;
   wgt::WgtAppQueryInterface query_interface;
-  auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer,
-                                            &query_interface);
-  std::unique_ptr<ci::InstallerFactory> installer_factory;
-  if (!pkgmgr) {
-    LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
-    return EINVAL;
-  }
+  try {
+    auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer,
+                                              &query_interface);
+    std::unique_ptr<ci::InstallerFactory> installer_factory;
+    if (!pkgmgr) {
+      LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
+      return EINVAL;
+    }
 
 #if __cplusplus >= 201300L
-  using std;
+    using std;
 #endif
-  // This is workaround for hybrid apps as they requires much different flow
-  // but installer does not branch at all in current design
-  if (query_interface.IsHybridApplication(
-      pkgmgr->GetRequestInfo(), pkgmgr->GetUid())) {
-    LOG(INFO) << "Hybrid package detected";
-    ci::InstallerRunner runner(
-        make_unique<hybrid::HybridInstallerFactory>(), pkgmgr);
-    return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
-  } else {
-    ci::InstallerRunner runner(make_unique<wgt::WgtInstallerFactory>(), pkgmgr);
-    return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
+    // This is workaround for hybrid apps as they requires much different flow
+    // but installer does not branch at all in current design
+    if (query_interface.IsHybridApplication(
+        pkgmgr->GetRequestInfo(), pkgmgr->GetUid())) {
+      LOG(INFO) << "Hybrid package detected";
+      ci::InstallerRunner runner(
+          make_unique<hybrid::HybridInstallerFactory>(), pkgmgr);
+      return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
+    } else {
+      ci::InstallerRunner runner(
+            make_unique<wgt::WgtInstallerFactory>(), pkgmgr);
+      return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
+    }
+  } catch(...) {
+    LOG(ERROR) << "Exception occured";
+    return 1;
   }
 }