[Feedback] Error codes adjusted to the documentation. 77/129877/1
authorTomasz Marciniak <t.marciniak@samsung.com>
Thu, 18 May 2017 08:37:21 +0000 (10:37 +0200)
committerTomasz Marciniak <t.marciniak@samsung.com>
Thu, 18 May 2017 08:37:21 +0000 (10:37 +0200)
[Verification] Code compiles.
TCT pass rate 100% (TW1)

Change-Id: I38fc1ad18b445253c0e87366c6c2841ebd54f13e
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/feedback/feedback_manager.cc

index 91e0e09..57f3e0c 100644 (file)
@@ -133,18 +133,23 @@ common::PlatformResult FeedbackManager::isPatternSupported(const std::string &pa
                                                            const std::string &type,
                                                            bool* patternStatus) {
   LoggerD("Entered");
+
   auto &pattern_e = m_feedbackMapsPtr->getPatternFromMap(pattern);
   auto &type_e = m_feedbackMapsPtr->getTypeFromMap(type);
+
   if (m_feedbackMapsPtr->isPatternSupportChecked(pattern_e, type_e)) {
     *patternStatus = m_feedbackMapsPtr->isPatternSupported(pattern_e, type_e);
     return PlatformResult(ErrorCode::NO_ERROR);
   }
+
   int ret = feedback_is_supported_pattern(type_e, pattern_e, patternStatus);
   if (ret != FEEDBACK_ERROR_NONE) {
     LoggerE("isPatternSupported failed: %d", ret);
-    return CodeToResult(ret, getFeedbackErrorMessage(ret).c_str());
+    return CodeToResult(FEEDBACK_ERROR_NOT_SUPPORTED, "Pattern not supported");
   }
+
   m_feedbackMapsPtr->setPatternSupport(pattern_e, type_e, *patternStatus);
+
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
@@ -156,9 +161,11 @@ common::PlatformResult FeedbackManager::play(const std::string &pattern, const s
   } else {
     bool patternSupport = false;
     auto result = isPatternSupported(pattern, type, &patternSupport);
+
     if (!result) {
       return result;
     }
+
     if (patternSupport) {
       ret = feedback_play_type(m_feedbackMapsPtr->getTypeFromMap(type),
                                m_feedbackMapsPtr->getPatternFromMap(pattern));
@@ -166,41 +173,45 @@ common::PlatformResult FeedbackManager::play(const std::string &pattern, const s
       return CodeToResult(FEEDBACK_ERROR_NOT_SUPPORTED, "Not supported device");
     }
   }
+
   if (ret != FEEDBACK_ERROR_NONE) {
     LoggerE("play failed: %d", ret);
     return CodeToResult(ret, getFeedbackErrorMessage(ret).c_str());
   }
+
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
 common::PlatformResult FeedbackManager::stop() {
   LoggerD("Entered");
+
   int ret = feedback_stop();
   if(ret != FEEDBACK_ERROR_NONE && ret != FEEDBACK_ERROR_NOT_SUPPORTED) {
     LoggerE("stop failed: %d", ret);
     return CodeToResult(ret, getFeedbackErrorMessage(ret).c_str());
-    }
+  }
+
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
 PlatformResult FeedbackManager::CodeToResult(const int errorCode,
                                      const std::string& message) {
   LoggerD("Entered");
+
   switch(errorCode) {
-    case FEEDBACK_ERROR_INVALID_PARAMETER:
-      return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, message);
-    case FEEDBACK_ERROR_OPERATION_FAILED:
-      return LogAndCreateResult(ErrorCode::SECURITY_ERR, message);
     case FEEDBACK_ERROR_NOT_SUPPORTED:
       return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, message);
+    case FEEDBACK_ERROR_INVALID_PARAMETER:
+    case FEEDBACK_ERROR_OPERATION_FAILED:
     case FEEDBACK_ERROR_NOT_INITIALIZED:
     default:
-      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, message);
+      return LogAndCreateResult(ErrorCode::ABORT_ERR, message);
   }
 }
 
 const std::string FeedbackManager::getFeedbackErrorMessage(const int error_code) {
   LoggerD("Error code : %d", error_code);
+
   switch(error_code) {
     case FEEDBACK_ERROR_OPERATION_FAILED:
       return "Operation not permitted";
@@ -211,7 +222,7 @@ const std::string FeedbackManager::getFeedbackErrorMessage(const int error_code)
     case FEEDBACK_ERROR_NOT_INITIALIZED:
       return "Not initialized";
     default:
-      return "UnknownError";
+      return "Abort Error";
   }
 }