Add to print key variable on error
authorChanggyu Choi <changyu.choi@samsung.com>
Fri, 21 Apr 2023 06:56:13 +0000 (15:56 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 25 Apr 2023 01:13:07 +0000 (10:13 +0900)
This patch adds to print key variable in app_control_get_extra_data()
for debugging.

Change-Id: Ida85e1457681f4b43bc93390a01783fa37ed4372
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/app-control/error.hh
src/app-control/exception.hh
src/app-control/stub.cc

index f0d9c3b34b698b1f105fb7b65dc24d14bf5aa688..5098a0e9518e53b801f10cb1bc1a4807b7807be8 100644 (file)
@@ -36,6 +36,38 @@ enum Error : int {
   IOError = TIZEN_ERROR_IO_ERROR,
 };
 
+constexpr const char* ErrorToString(int error) {
+  switch (error) {
+    case Error::None:
+      return "None";
+    case Error::InvalidParameter:
+      return "InvalidParameter";
+    case Error::OutOfMemory:
+      return "OutOfMemory";
+    case Error::AppNotFound:
+      return "AppNotFound";
+    case Error::KeyNotFound:
+      return "KeyNotFound";
+    case Error::KeyRejected:
+      return "KeyRejected";
+    case Error::InvalidDataType:
+      return "InvalidDataType";
+    case Error::LaunchRejected:
+      return "LaunchRejected";
+    case Error::PermissionDenied:
+      return "PermissionDenied";
+    case Error::LaunchFailed:
+      return "LaunchFailed";
+    case Error::TimedOut:
+      return "TimedOut";
+    case Error::IOError:
+      return "IOError";
+    default:
+      return "Unknown";
+  }
+  return "Unknown";
+}
+
 }  // namespace app_control
 
 #endif  // APP_CONTROL_ERROR_HH_
index 05ab5d382b110b3d16c278d45d24938d2bf19d2b..2a9d090052089cb26b61b9649fe024c727476ad6 100644 (file)
@@ -17,8 +17,8 @@
 #ifndef APP_CONTROL_EXCEPTION_HH_
 #define APP_CONTROL_EXCEPTION_HH_
 
-#include <string>
 #include <exception>
+#include <string>
 
 #include "app-control/log_private.hh"
 
@@ -29,10 +29,9 @@ namespace app_control {
 class Exception : public std::exception {
  public:
   explicit Exception(int error_code, std::string file = __FILE__,
-      int line = __LINE__ ) {
-    error_code_ = error_code;
+      int line = __LINE__) : error_code_(error_code) {
     message_ = file.substr(file.find_last_of("/") + 1) + ":"
-        + std::to_string(line) + " code:" + std::to_string(error_code_);
+        + std::to_string(line) + " code:" + ErrorToString(error_code_);
   }
 
   virtual ~Exception() {}
index 031746fa4dae6cf2e70b3acc327a475f69b8bbfa..2919676465b8b7cfff881e8d184f365162e2a42e 100644 (file)
@@ -726,7 +726,9 @@ EXPORT int app_control_get_extra_data(app_control_h app_control,
       return APP_CONTROL_ERROR_OUT_OF_MEMORY;
     }
   } catch (Exception& e) {
-    _E("Failed to get extra data. error(%d)", e.GetErrorCode());
+    _E("Failed to get extra data. error(%s). key: %s",
+        ErrorToString(e.GetErrorCode()), key);
+
     return e.GetErrorCode();
   }