[Application] Added error messages.
authorTomasz Marciniak <t.marciniak@samsung.com>
Mon, 19 Oct 2015 09:28:35 +0000 (11:28 +0200)
committerTomasz Marciniak <t.marciniak@samsung.com>
Mon, 19 Oct 2015 09:28:35 +0000 (11:28 +0200)
[Features] Commit migrated from tv branch.
http://165.213.149.170/gerrit/#/c/77630/

[Verification] Code compiles. TCT 100%

Change-Id: Id2d4ce27adf049eba1f6a8e77b9060289a5b0e2e
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/application/application_manager.cc
src/application/application_utils.cc
src/application/requested_application_control.cc

index b919e09b22b76e0fa87d1e86096491b7cd28fad5..d505eea55052a0223e24eecb4ab9891f4a15b651 100755 (executable)
@@ -110,7 +110,7 @@ void ApplicationManager::GetCurrentApplication(const std::string& app_id,
   pkgmgrinfo_appinfo_h handle;
   int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle);
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get app info.");
+    LoggerE("Failed to get app info: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get app info."), out);
     return;
   }
@@ -186,14 +186,15 @@ class TerminateHandler {
     std::shared_ptr<picojson::value> response{new picojson::value(picojson::object())};
 
     LoggerD("checking if application is still alive");
-    if (app_manager_get_app_id(that->pid_, &app_id) == APP_MANAGER_ERROR_NONE) {
+    int ret = app_manager_get_app_id(that->pid_, &app_id);
+    if (APP_MANAGER_ERROR_NONE == ret) {
         LoggerD("application is alive - failure");
         free(app_id);
         // context is still alive, report error
         ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to kill application."),
                     &response->get<picojson::object>());
     } else {
-        LoggerD("application is dead - success");
+      LoggerD("application is dead - success: %d (%s)", ret, get_error_message(ret));
         ReportSuccess(response->get<picojson::object>());
     }
 
@@ -302,7 +303,7 @@ void ApplicationManager::Kill(const picojson::value& args) {
     std::unique_ptr<char, void(*)(void*)> app_id_ptr(app_id, &std::free);
 
     if (APP_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Failed to get application ID, error: %d", ret);
+      LoggerE("Failed to get application ID, error: %d (%s)", ret, get_error_message(ret));
       result = PlatformResult(ErrorCode::NOT_FOUND_ERR, "Failed to get application ID.");
       CHECK_RESULT(result, response, handler)
     }
@@ -317,7 +318,7 @@ void ApplicationManager::Kill(const picojson::value& args) {
     app_context_ptr(app_context, &app_context_destroy); // automatically release the memory
 
     if (APP_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Failed to get application context handle");
+      LoggerE("Failed to get application context handle: %d (%s)", ret, get_error_message(ret));
       result = PlatformResult(ErrorCode::NOT_FOUND_ERR, "Failed to get application ID.");
       CHECK_RESULT(result, response, handler)
     }
@@ -336,7 +337,7 @@ void ApplicationManager::Kill(const picojson::value& args) {
       int ret = app_context_get_pid(app_context, &pid);
 
       if (APP_MANAGER_ERROR_NONE != ret) {
-        LoggerE("Failed to get pid of terminated app (%d)", ret);
+        LoggerE("Failed to get pid of terminated app: %d (%s)", ret, get_error_message(ret));
         return;
       }
 
@@ -358,7 +359,7 @@ void ApplicationManager::Kill(const picojson::value& args) {
     ret = app_manager_set_app_context_event_cb(terminate_callback, handler);
 
     if (APP_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Error while registering app context event (%d)", ret);
+      LoggerE("Error while registering app context event: %d (%s)", ret, get_error_message(ret));
       result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to register termination callback.");
       CHECK_RESULT(result, response, handler)
     }
@@ -374,7 +375,7 @@ void ApplicationManager::Kill(const picojson::value& args) {
     ret = app_manager_terminate_app(app_context);
 
     if (APP_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Failed to terminate application.");
+      LoggerE("Failed to terminate application: %d (%s)", ret, get_error_message(ret));
       result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to terminate application.");
       CHECK_RESULT(result, response, handler)
     }
@@ -433,6 +434,7 @@ void ApplicationManager::Launch(const picojson::value& args) {
     if (ret < 0) {
       result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error has occurred.");
 
+      LoggerD("Aul open return: %d (%s)", ret, get_error_message(ret));
       switch (ret) {
         case AUL_R_EINVAL:
         case AUL_R_ERROR:
@@ -524,7 +526,7 @@ void ApplicationManager::LaunchAppControl(const picojson::value& args) {
       int ret = app_control_set_app_id(app_control_ptr.get(), app_id.c_str());
 
       if (APP_CONTROL_ERROR_NONE != ret) {
-        LoggerE("Invalid parameter passed.");
+        LoggerE("Failed to set app id: %d (%s)", ret, get_error_message(ret));
         ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."),
                     &response->get<picojson::object>());
         return;
@@ -547,7 +549,7 @@ void ApplicationManager::LaunchAppControl(const picojson::value& args) {
 
       int ret = app_control_set_launch_mode(app_control_ptr.get(), launch_mode);
       if (APP_CONTROL_ERROR_NONE != ret) {
-        LoggerE("Setting launch mode failed.");
+        LoggerE("Setting launch mode failed: %d (%s)", ret, get_error_message(ret));
         ReportError(PlatformResult(ErrorCode::NOT_FOUND_ERR, "Setting launch mode failed."),
                     &response->get<picojson::object>());
         return;
@@ -635,7 +637,7 @@ void ApplicationManager::LaunchAppControl(const picojson::value& args) {
                       &response->get<picojson::object>());
           return;
         default:
-          LoggerE("app_control_send_launch_request returns UNKNOWN ERROR!!!");
+          LoggerE("app_control_send_launch_request returns: %d (%s)", ret, get_error_message(ret));
           ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error."),
                       &response->get<picojson::object>());
           return;
@@ -698,7 +700,7 @@ void ApplicationManager::FindAppControl(const picojson::value& args) {
       pkgmgrinfo_appinfo_h handle;
       int ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
       if (PMINFO_R_OK != ret) {
-        LoggerE("Failed to get appInfo");
+        LoggerE("Failed to get appInfo: %d (%s)", ret, get_error_message(ret));
       } else {
         picojson::array* array = static_cast<picojson::array*>(user_data);
         array->push_back(picojson::value(picojson::object()));
@@ -720,7 +722,7 @@ void ApplicationManager::FindAppControl(const picojson::value& args) {
         app_control_ptr.get(), app_control_matched, &array.first->second.get<picojson::array>());
 
     if (APP_CONTROL_ERROR_NONE != ret) {
-      LoggerE("app_control_foreach_app_matched error: %d", ret);
+      LoggerE("app_control_foreach_app_matched error: %d (%s)", ret, get_error_message(ret));
 
       ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR,"Unknown error"), &response_obj);
       // remove copied ApplicationControl from result
@@ -779,7 +781,7 @@ void ApplicationManager::GetAppsContext(const picojson::value& args) {
     int ret = app_manager_foreach_app_context(app_context_cb, &array);
 
     if (APP_MANAGER_ERROR_NONE != ret) {
-      LoggerE("app_manager_foreach_app_context error");
+      LoggerE("app_manager_foreach_app_context error: %d (%s)", ret, get_error_message(ret));
       ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error."), &response_obj);
     } else {
       ReportSuccess(result, response_obj);
@@ -837,7 +839,7 @@ void ApplicationManager::GetAppContext(const picojson::value& args, picojson::ob
         return;
 
       default:
-        LoggerE("app_manager_get_app_id returned: %d", ret);
+        LoggerE("app_manager_get_app_id returned: %d (%s)", ret, get_error_message(ret));
         ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error."), out);
         return;
     }
@@ -882,7 +884,7 @@ void ApplicationManager::GetAppsInfo(const picojson::value& args) {
     int ret = pkgmgrinfo_appinfo_get_installed_list(app_info_cb, &array);
 
     if (APP_MANAGER_ERROR_NONE != ret) {
-      LoggerE("pkgmgrinfo_appinfo_get_installed_list error");
+      LoggerE("pkgmgrinfo_appinfo_get_installed_list error: %d (%s)", ret, get_error_message(ret));
       ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error."), &response_obj);
     } else {
       ReportSuccess(result, response_obj);
@@ -909,8 +911,9 @@ void ApplicationManager::GetAppInfo(const std::string& app_id, picojson::object*
 
   pkgmgrinfo_appinfo_h handle = nullptr;
 
-  if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle)) {
-    LoggerE("Failed to get app info");
+  int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle);
+  if (PMINFO_R_OK != ret) {
+    LoggerE("Failed to get app info: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::NOT_FOUND_ERR, "Failed to get app info."), out);
     return;
   }
@@ -929,19 +932,19 @@ char* ApplicationManager::GetPackageId(const std::string& app_id) {
 
   int ret = app_manager_get_app_info(app_id.c_str(), &handle);
   if (APP_MANAGER_ERROR_NONE != ret) {
-    LoggerE("Failed to get app info.");
+    LoggerE("Failed to get app info: %d (%s)", ret, get_error_message(ret));
     return nullptr;
   }
 
   ret = app_info_get_package(handle, &pkg_id);
   if (APP_MANAGER_ERROR_NONE != ret) {
-    LoggerE("Failed to get package id.");
+    LoggerE("Failed to get package id: %d (%s)", ret, get_error_message(ret));
     pkg_id = nullptr;
   }
 
   ret = app_info_destroy(handle);
   if (APP_MANAGER_ERROR_NONE != ret) {
-    LoggerE("Failed to destroy app info.");
+    LoggerE("Failed to destroy app info: %d (%s)", ret, get_error_message(ret));
   }
 
   return pkg_id;
@@ -969,7 +972,7 @@ void ApplicationManager::GetAppCerts(const std::string& app_id, picojson::object
   pkg_info_ptr(pkg_info, &package_info_destroy); // automatically release the memory
 
   if (PACKAGE_MANAGER_ERROR_NONE != ret) {
-    LoggerE("Failed to get package info.");
+    LoggerE("Failed to get package info: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get package info."), out);
     return;
   }
@@ -1025,7 +1028,7 @@ void ApplicationManager::GetAppCerts(const std::string& app_id, picojson::object
   ret = package_info_foreach_cert_info(pkg_info, cert_info_cb, &result.get<picojson::array>());
 
   if ((PACKAGE_MANAGER_ERROR_NONE != ret) && (PACKAGE_MANAGER_ERROR_IO_ERROR != ret)) {
-    LoggerE("Failed to get certificates info.");
+    LoggerE("Failed to get certificates info: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get certificates info."), out);
     return;
   }
@@ -1055,7 +1058,7 @@ void ApplicationManager::GetAppSharedUri(const std::string& app_id, picojson::ob
   pkg_info_ptr(pkg_info, &pkgmgrinfo_pkginfo_destroy_pkginfo); // automatically release the memory
 
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get package info.");
+    LoggerE("Failed to get package info: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get package info."), out);
     return;
   }
@@ -1064,7 +1067,7 @@ void ApplicationManager::GetAppSharedUri(const std::string& app_id, picojson::ob
   ret = pkgmgrinfo_pkginfo_get_root_path(pkg_info, &root_path);
 
   if (PMINFO_R_OK != ret || nullptr == root_path) {
-    LoggerE("Failed to get root path.");
+    LoggerE("Failed to get root path: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get root path."), out);
     return;
   }
@@ -1087,7 +1090,7 @@ void ApplicationManager::GetAppMetaData(const std::string& app_id, picojson::obj
   pkg_info_ptr(handle, &pkgmgrinfo_appinfo_destroy_appinfo); // automatically release the memory
 
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get app info.");
+    LoggerE("Failed to get app info: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::NOT_FOUND_ERR, "Failed to get app info."), out);
     return;
   }
@@ -1110,7 +1113,7 @@ void ApplicationManager::GetAppMetaData(const std::string& app_id, picojson::obj
   ret = pkgmgrinfo_appinfo_foreach_metadata(handle, meta_data_cb, &result.get<picojson::array>());
 
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get metadata.");
+    LoggerE("Failed to get metadata: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get metadata."), out);
     return;
   }
@@ -1214,8 +1217,10 @@ class ApplicationListChangedBroker {
         case Event::kUpdated:
         {
           pkgmgrinfo_appinfo_h handle = nullptr;
-          if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle)) {
-            LoggerE("Failed to get application information handle.");
+          int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle);
+          if (PMINFO_R_OK != ret) {
+            LoggerE("Failed to get application information handle: %d (%s)",
+                    ret, get_error_message(ret));
             continue;
           }
           auto info = data_obj.insert(std::make_pair(kData, picojson::value(picojson::object())));
@@ -1243,7 +1248,7 @@ class ApplicationListChangedBroker {
 
     int ret = package_info_create(package, &package_info);
     if (PACKAGE_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Failed to create package info");
+      LoggerE("Failed to create package info: %d (%s)", ret, get_error_message(ret));
       return;
     }
 
@@ -1252,12 +1257,12 @@ class ApplicationListChangedBroker {
                                                 ApplicationIdCallback,
                                                 this);
     if (PACKAGE_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Failed to get application IDs");
+      LoggerE("Failed to get application IDs: %d (%s)", ret, get_error_message(ret));
     }
 
     ret = package_info_destroy(package_info);
     if (PACKAGE_MANAGER_ERROR_NONE != ret) {
-      LoggerE("Failed to destroy package info");
+      LoggerE("Failed to destroy package info: %d (%s)", ret, get_error_message(ret));
     }
   }
 
@@ -1403,7 +1408,7 @@ void ApplicationManager::GetApplicationInformationSize(const picojson::value& ar
                                          package_id_str.c_str(), NULL, NULL, NULL);
 
     if (size < 0) {
-      LoggerE("Failed to get installed size");
+      LoggerE("Failed to get installed size: %d (%s)", size, get_error_message(size));
     }
 
     pkgmgr_client_free(pc);
@@ -1434,7 +1439,7 @@ void ApplicationManager::BroadcastEventHelper(
   ret = bundle_add(data, "data", args.get("data").serialize().c_str());
 
   if (ret != EVENT_ERROR_NONE) {
-    LoggerE("bundle_add failed, error");
+    LoggerE("bundle_add failed, error: %d (%s)", ret, get_error_message(ret));
     ReportError(out);
     return;
   }
@@ -1448,7 +1453,7 @@ void ApplicationManager::BroadcastEventHelper(
   if (ret == EVENT_ERROR_NONE) {
     ReportSuccess(out);
   } else {
-    LoggerE("event_publish_app_event failed, error");
+    LoggerE("event_publish_app_event failed, error: %d (%s)", ret, get_error_message(ret));
     ReportError(out);
   }
 }
@@ -1478,20 +1483,20 @@ void ApplicationManager::OnEvent(const char* event_name,
     if (key != "") {
       ret = bundle_get_str(event_data, key.c_str(), &val);
       if (EVENT_ERROR_NONE != ret) {
-        LOGGER(ERROR) << "failed to read bundle data, error: " << ret;
+        LoggerE("failed to read bundle data, error: %d (%s)", ret, get_error_message(ret));
         return;
       }
 
       state = std::string(val);
     }
 
-    LOGGER(DEBUG) << "state is: " << state;
+    LoggerD("State is %s", state.c_str());
     event_o["value"] = picojson::value(state);
 
   } else { // user event
     ret = bundle_get_str(event_data, "data", &val);
     if (EVENT_ERROR_NONE != ret) {
-      LOGGER(ERROR) << "failed to read bundle data, error: " << ret;
+      LoggerE("failed to read bundle data, error: %d (%s)", ret, get_error_message(ret));
       return;
     }
 
@@ -1520,7 +1525,7 @@ PlatformResult ApplicationManager::StartEventListener(const std::string& event_n
   event_handler_h event_handler;
 
   ret = event_add_event_handler(event_name.c_str(), OnEvent, this, &event_handler);
-  LOGGER(DEBUG) << "event_add_event_handler() result: " << ret;
+  LoggerD("event_add_event_handler() result: %d (%s)", ret, get_error_message(ret));
   if (EVENT_ERROR_PERMISSION_DENIED == ret) {
     LOGGER(ERROR) << "event_add_event_handler failed, error: " << ret;
     return PlatformResult(ErrorCode::SECURITY_ERR, "The privilege is required");
@@ -1547,7 +1552,7 @@ void ApplicationManager::StopEventListener(const std::string& event_name) {
 
     ret = event_remove_event_handler(event_handler);
     if (EVENT_ERROR_NONE != ret) {
-      LOGGER(ERROR) << "event_remove_event_handler failed, error: " << ret;
+      LoggerE("event_remove_event_handler failed, error: %d (%s)", ret, get_error_message(ret));
       return;
     }
 
index fabc343996c1b2bc5211b9145f92eb4976877235..c6a871e36aee1dd622e3dbcb86d5901ca0fa7969 100755 (executable)
@@ -38,7 +38,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
   // application ID
   ret = pkgmgrinfo_appinfo_get_appid(handle, &tmp_str);
   if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) {
-    LoggerE("Failed to get appid");
+    LoggerE("Failed to get appid: %d (%s)", ret, get_error_message(ret));
   } else {
     app_info->insert(std::make_pair("id", picojson::value(tmp_str)));
   }
@@ -47,7 +47,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
   // name
   ret = pkgmgrinfo_appinfo_get_label(handle, &tmp_str);
   if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) {
-    LoggerE("Failed to get label");
+    LoggerE("Failed to get label: %d (%s)", ret, get_error_message(ret));
   } else {
     app_info->insert(std::make_pair("name", picojson::value(tmp_str)));
   }
@@ -56,7 +56,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
   // icon path
   ret = pkgmgrinfo_appinfo_get_icon(handle, &tmp_str);
   if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) {
-    LoggerE("Failed to get icon path");
+    LoggerE("Failed to get icon path: %d (%s)", ret, get_error_message(ret));
   } else {
     app_info->insert(std::make_pair("iconPath", picojson::value(tmp_str)));
   }
@@ -66,7 +66,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
   bool no_display = false;
   ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &no_display);
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get nodisplay");
+    LoggerE("Failed to get nodisplay: %d (%s)", ret, get_error_message(ret));
   } else {
     app_info->insert(std::make_pair("show", picojson::value(!no_display)));
   }
@@ -90,13 +90,13 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
   &categories_array);
 
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get categories");
+    LoggerE("Failed to get categories: %d (%s)", ret, get_error_message(ret));
   }
 
   // package ID
   ret = pkgmgrinfo_appinfo_get_pkgid(handle, &tmp_str);
   if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) {
-    LoggerE("Failed to get pkgid");
+    LoggerE("Failed to get pkgid: %d (%s)", ret, get_error_message(ret));
   } else {
     app_info->insert(std::make_pair("packageId", picojson::value(tmp_str)));
   }
@@ -104,13 +104,13 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
   pkgmgrinfo_pkginfo_h pkginfo;
   ret = pkgmgrinfo_pkginfo_get_pkginfo(tmp_str, &pkginfo);
   if (PMINFO_R_OK != ret) {
-    LoggerE("Failed to get package info");
+    LoggerE("Failed to get package info: %d (%s)", ret, get_error_message(ret));
   } else {
     // version
     tmp_str = nullptr;
     ret = pkgmgrinfo_pkginfo_get_version(pkginfo, &tmp_str);
     if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) {
-      LoggerE("Failed to get version");
+      LoggerE("Failed to get version: %d (%s)", ret, get_error_message(ret));
     } else {
       app_info->insert(std::make_pair("version", picojson::value(tmp_str)));
     }
@@ -119,7 +119,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h
     int installed_time = 0;
     ret = pkgmgrinfo_pkginfo_get_installed_time(pkginfo, &installed_time);
     if (ret != PMINFO_R_OK) {
-      LoggerE("Fail to get installed date");
+      LoggerE("Fail to get installed date: %d (%s)", ret, get_error_message(ret));
     } else {
       app_info->insert(std::make_pair("installDate", picojson::value(1000.0 * installed_time)));
     }
@@ -139,7 +139,7 @@ bool ApplicationUtils::CreateApplicationContext(const app_context_h handle,
   std::unique_ptr<char, void(*)(void*)> app_id_ptr(app_id, &std::free);
 
   if ((APP_MANAGER_ERROR_NONE != ret) || (nullptr == app_id)) {
-    LoggerD("Failed to get application ID from context.");
+    LoggerD("Failed to get application ID from context: %d (%s)", ret, get_error_message(ret));
     return false;
   }
 
@@ -147,7 +147,7 @@ bool ApplicationUtils::CreateApplicationContext(const app_context_h handle,
   ret = app_context_get_pid(handle, &pid);
 
   if(ret != APP_MANAGER_ERROR_NONE) {
-    LoggerD("Failed to get pid from context.");
+    LoggerD("Failed to get pid from context: %d (%s)", ret, get_error_message(ret));
     return false;
   }
 
@@ -296,6 +296,8 @@ void ApplicationUtils::ServiceToApplicationControl(app_control_h app_control,
   if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
     LoggerD("operation: %s", tmp_str);
     app_control_obj->insert(std::make_pair("operation", picojson::value(std::string(tmp_str))));
+  } else {
+    LoggerE("Get operation failed: %d (%s)", ret, get_error_message(ret));
   }
   clear(tmp_str);
 
@@ -310,6 +312,8 @@ void ApplicationUtils::ServiceToApplicationControl(app_control_h app_control,
   if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
     LoggerD("MIME: %s", tmp_str);
     app_control_obj->insert(std::make_pair("mime", picojson::value(std::string(tmp_str))));
+  } else {
+    LoggerE("Get mime failed: %d (%s)", ret, get_error_message(ret));
   }
   clear(tmp_str);
 
@@ -317,6 +321,8 @@ void ApplicationUtils::ServiceToApplicationControl(app_control_h app_control,
   if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
     LoggerD("category: %s", tmp_str);
     app_control_obj->insert(std::make_pair("category", picojson::value(std::string(tmp_str))));
+  } else {
+    LoggerE("Get category failed: %d (%s)", ret, get_error_message(ret));
   }
   clear(tmp_str);
 
@@ -336,7 +342,8 @@ void ApplicationUtils::ServiceExtraDataToApplicationControlData(app_control_h ap
   ret = app_control_is_extra_data_array(app_control, key.c_str(), &is_array);
 
   if (APP_CONTROL_ERROR_NONE != ret) {
-    LoggerE("Failed to check whether extra data is array or not");
+    LoggerE("Failed to check whether extra data is array or not: %d (%s)", ret,
+            get_error_message(ret));
     return;
   }
 
@@ -358,7 +365,7 @@ void ApplicationUtils::ServiceExtraDataToApplicationControlData(app_control_h ap
       }
       free(value);
     } else {
-      LoggerE("Failed to get extra data array, errno: %d", ret);
+      LoggerE("Failed to get extra data array, errno: %d (%s)", ret, get_error_message(ret));
     }
   } else {
     char* value = nullptr;
@@ -369,7 +376,7 @@ void ApplicationUtils::ServiceExtraDataToApplicationControlData(app_control_h ap
       value_array.push_back(picojson::value(value));
       free(value);
     } else {
-      LoggerE("Failed to get extra data, errno: %d", ret);
+      LoggerE("Failed to get extra data, errno: %d (%s)", ret, get_error_message(ret));
     }
   }
 
index de6bffd89458b42ab6fef4d28d85b1dcdbe4ee2f..380e828758b0a0ad4f3f3e2ad36dd807f0f2c62a 100755 (executable)
@@ -45,7 +45,7 @@ PlatformResult RequestedApplicationControl::set_bundle(const std::string& encode
     bundle_free(bundle);
 
     if (APP_CONTROL_ERROR_NONE != ret) {
-      LoggerE("Failed to create app_control");
+      LoggerE("Failed to create app_control: %d (%s)", ret, get_error_message(ret));
       return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to create app_control.");
     }
 
@@ -66,7 +66,8 @@ void RequestedApplicationControl::set_app_control(app_control_h app_control) {
   if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
     caller_app_id_ = tmp_str;
   } else {
-    LoggerW("Failed to get callerAppId because of platform error");
+    LoggerW("Failed to get callerAppId because of platform error: %d (%s)", ret,
+            get_error_message(ret));
     LoggerW("Please ignore if the application is launched in debug mode");
   }
 
@@ -136,9 +137,10 @@ void RequestedApplicationControl::ReplyResult(const picojson::value& args, picoj
   }
 
   // send reply
-  if (APP_CONTROL_ERROR_NONE !=
-      app_control_reply_to_launch_request(reply, app_control_.get(), APP_CONTROL_RESULT_SUCCEEDED)) {
-    LoggerE("Cannot find caller.");
+  int ret = app_control_reply_to_launch_request(
+      reply, app_control_.get(), APP_CONTROL_RESULT_SUCCEEDED);
+  if (APP_CONTROL_ERROR_NONE != ret) {
+    LoggerE("Cannot find caller: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::NOT_FOUND_ERR, "Cannot find caller."), out);
     return;
   }
@@ -176,7 +178,7 @@ void RequestedApplicationControl::ReplyFailure(picojson::object* out) {
   // send reply
   int ret = app_control_reply_to_launch_request(reply, app_control_.get(), APP_CONTROL_RESULT_FAILED);
   if (APP_CONTROL_ERROR_NONE != ret) {
-    LoggerE("Cannot find caller.");
+    LoggerE("Cannot find caller: %d (%s)", ret, get_error_message(ret));
     ReportError(PlatformResult(ErrorCode::NOT_FOUND_ERR, "Cannot find caller."), out);
     return;
   }
@@ -212,7 +214,7 @@ PlatformResult RequestedApplicationControl::VerifyCallerPresence() {
     int ret = app_manager_is_running(caller_app_id_.c_str(), &running);
 
     if ((APP_MANAGER_ERROR_NONE != ret) || !running) {
-      LoggerE("Caller is not running");
+      LoggerE("Caller is not running: %d (%s)", ret, get_error_message(ret));
       return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Cannot find caller.");
     }