[Messaging] - Refactoring logs
authorAndrzej Popowski <a.popowski@samsung.com>
Fri, 27 Nov 2015 15:15:37 +0000 (16:15 +0100)
committerAndrzej Popowski <a.popowski@samsung.com>
Mon, 30 Nov 2015 13:29:57 +0000 (14:29 +0100)
Change-Id: Ideb1a83c7e6584f0a6d5cff8166fe5a5553755be
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
17 files changed:
src/messaging/DBus/LoadAttachmentProxy.cpp
src/messaging/DBus/LoadBodyProxy.cpp
src/messaging/DBus/MessageProxy.cpp
src/messaging/DBus/SendProxy.cpp
src/messaging/DBus/SyncProxy.cpp
src/messaging/email_manager.cc
src/messaging/message.cc
src/messaging/message_body.cc
src/messaging/message_conversation.cc
src/messaging/message_service.cc
src/messaging/message_service_email.cc
src/messaging/message_service_short_msg.cc
src/messaging/messaging_database_manager.cc
src/messaging/messaging_instance.cc
src/messaging/messaging_manager.cc
src/messaging/messaging_util.cc
src/messaging/short_message_manager.cc

index 115f3750393cc29029fa6855ad6f137d721df25e..e6fa2dba2d12a8b9b3add4b0c201d6abc3d993a2 100644 (file)
@@ -73,8 +73,9 @@ PlatformResult updateAttachmentDataWithEmailGetAttachmentData(
     int err = email_get_attachment_data(attachment->getId(), &attachment_data_holder.data);
     if (EMAIL_ERROR_NONE != err ||
         NULL == attachment_data_holder.data) {
-        LoggerE("Couldn't get attachment data for attachmentId:%d", attachment->getId());
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.",
+                  ("Couldn't get attachment data for attachmentId:%d", attachment->getId()));
     }
 
     LoggerD("attachment name : %s", attachment_data_holder->attachment_name);
@@ -111,9 +112,8 @@ PlatformResult LoadAttachmentProxy::create(const std::string& path,
                                            LoadAttachmentProxyPtr* load_attachment_proxy) {
     load_attachment_proxy->reset(new LoadAttachmentProxy(path, iface));
     if ((*load_attachment_proxy)->isNotProxyGot()) {
-        LoggerE("Could not get load attachment proxy");
         load_attachment_proxy->reset();
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get load attachment proxy");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get load attachment proxy");
     } else {
         return PlatformResult(ErrorCode::NO_ERROR);
     }
@@ -198,7 +198,7 @@ void LoadAttachmentProxy::handleEmailSignal(const int status,
     LoggerD("Found callback for pair mailId:%d nth:%d", mail_id, nth);
 
     PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    if(NOTI_DOWNLOAD_ATTACH_FINISH == status) {
+    if (NOTI_DOWNLOAD_ATTACH_FINISH == status) {
         LoggerD("Message attachment downloaded!");
 
         std::shared_ptr<MessageAttachment> att = callback->getMessageAttachment();
@@ -213,9 +213,8 @@ void LoadAttachmentProxy::handleEmailSignal(const int status,
             callback->SetSuccess(picojson::value(args));
             callback->Post();
         }
-    } else if(NOTI_DOWNLOAD_ATTACH_FAIL) {
-        LoggerD("Load message attachment failed!");
-        ret = PlatformResult(ErrorCode::UNKNOWN_ERR, "Load message attachment failed!");
+    } else if (NOTI_DOWNLOAD_ATTACH_FAIL == status) {
+        ret = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Load message attachment failed!");
     }
     if (ret.IsError()) {
         LoggerE("Exception in signal callback");
index 8916409c57182996fb112443b552f342774d3949..5b64e02d6e3156df80699c90b736f266d7dca8c9 100644 (file)
@@ -62,9 +62,8 @@ PlatformResult LoadBodyProxy::create(const std::string& path,
                                      LoadBodyProxyPtr* load_body_proxy) {
     load_body_proxy->reset(new LoadBodyProxy(path, iface));
     if ((*load_body_proxy)->isNotProxyGot()) {
-        LoggerE("Could not get load body proxy");
         load_body_proxy->reset();
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get load body proxy");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get load body proxy");
     } else {
         return PlatformResult(ErrorCode::NO_ERROR);
     }
@@ -174,8 +173,7 @@ void LoadBodyProxy::handleEmailSignal(const int status,
                 callback->Post();
             }
         } else if(NOTI_DOWNLOAD_BODY_FAIL == status) {
-            LoggerD("Load message body failed!");
-            ret = PlatformResult(ErrorCode::UNKNOWN_ERR, "Load message body failed!");
+            ret = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Load message body failed!");
         }
 
         if (ret.IsError()) {
index d0c1d3f54022cda154e71fa93a750a8f8a498ea2..c2354a1182dd4e68d2d6f2cb504c3ad2e873a013 100644 (file)
@@ -48,9 +48,8 @@ MessageProxy::~MessageProxy()
 PlatformResult MessageProxy::create(MessageProxyPtr* message_proxy) {
     message_proxy->reset(new MessageProxy());
     if ((*message_proxy)->isNotProxyGot()) {
-        LoggerE("Could not get proxy");
         message_proxy->reset();
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get proxy");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get proxy");
     } else {
         return PlatformResult(ErrorCode::NO_ERROR);
     }
@@ -123,13 +122,15 @@ PlatformResult MessageProxy::handleEmailEvent(int account_id, int mail_id, int t
         //getting thread_id from message
         email_mail_data_t *mail_data = NULL;
 
-        if(EMAIL_ERROR_NONE != email_get_mail_data(mail_id, &mail_data)) {
+        int ntv_ret = email_get_mail_data(mail_id, &mail_data);
+        if(EMAIL_ERROR_NONE != ntv_ret) {
           if (mail_data) email_free_mail_data(&mail_data, 1);
 
-          LoggerE("Failed to get mail data during setting conversation id in MessageProxy.");
-          return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                "Failed to get mail data during setting"
-                                " conversation id in MessageProxy.");
+          return LogAndCreateResult(
+                    ErrorCode::UNKNOWN_ERR,
+                    "Failed to get mail data during setting"
+                       " conversation id in MessageProxy.",
+                    ("email_get_mail_data error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
         }
 
         thread_id = mail_data->thread_id;
@@ -141,7 +142,7 @@ PlatformResult MessageProxy::handleEmailEvent(int account_id, int mail_id, int t
 
       email_mail_data_t* mail_data = EmailManager::getInstance().loadMessage(mail_id);
       if (mail_data == NULL) {
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to load email");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to load email");
       }
       std::shared_ptr<Message> msg;
       PlatformResult ret = Message::convertPlatformEmailToObject(*mail_data, &msg);
@@ -280,10 +281,13 @@ PlatformResult MessageProxy::handleMailboxEvent(int account_id, int mailbox_id,
                 false));
     } else {
         email_mailbox_t* mail_box = NULL;
-        if (EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_id(mailbox_id, &mail_box)) {
-            LoggerE("Mailbox not retrieved");
+        int ntv_ret = email_get_mailbox_by_mailbox_id(mailbox_id, &mail_box);
+        if (EMAIL_ERROR_NONE != ntv_ret) {
             delete eventFolder;
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to load mailbox");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Failed to load mailbox",
+                      ("email_get_mailbox_by_mailbox_id error: %d (%s)",
+                          ntv_ret, get_error_message(ntv_ret)));
         }
         folder.reset(new MessageFolder(*mail_box));
         if (EMAIL_ERROR_NONE != email_free_mailbox(&mail_box, 1)) {
index 7e567a96107e84b52040c409849978607798e5dc..cc0a16f6dff0cc5f70dc1bf65ba1211952bd4038 100644 (file)
@@ -42,9 +42,8 @@ SendProxy::~SendProxy()
 PlatformResult SendProxy::create(SendProxyPtr* send_proxy) {
     send_proxy->reset(new SendProxy());
     if ((*send_proxy)->isNotProxyGot()) {
-        LoggerE("Could not get send proxy");
         send_proxy->reset();
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get send proxy");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get send proxy");
     } else {
         return PlatformResult(ErrorCode::NO_ERROR);
     }
index ea096c7585a90dc53c9e630ad524b6fe2b928f4b..7ce525ef3b4c37d6c73a1d2534c8f13984422787 100644 (file)
@@ -49,9 +49,8 @@ PlatformResult SyncProxy::create(const std::string& path,
                                  SyncProxyPtr* sync_proxy) {
     sync_proxy->reset(new SyncProxy(path, iface));
     if ((*sync_proxy)->isNotProxyGot()) {
-        LoggerE("Could not get sync proxy");
         sync_proxy->reset();
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get sync proxy");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get sync proxy");
     } else {
         return PlatformResult(ErrorCode::NO_ERROR);
     }
@@ -131,8 +130,7 @@ void SyncProxy::handleEmailSignal(const int status,
             break;
 
         case NOTI_DOWNLOAD_FAIL:
-            LoggerD("Sync failed!");
-            callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Sync failed!"));
+            callback->SetError(LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Sync failed!"));
             callback->Post();
             break;
 
@@ -160,8 +158,9 @@ PlatformResult SyncProxy::findSyncCallbackByOpHandle(const int op_handle,
     // map with specified opId (for example stopSync() has
     // removed it), but sync() was already started - only
     // warning here:
-    LoggerW("Could not find callback with op_handle: %d", op_handle);
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not find callback");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Could not find callback",
+              ("Could not find callback with op_handle: %d", op_handle));
 }
 
 } //namespace DBus
index c7fbbf77b94be551653b2bdb33b334b9916d3777..2e15dd17ca64e9ca3ecbb63adca1c83869ded2f7 100755 (executable)
@@ -96,16 +96,19 @@ PlatformResult EmailManager::InitializeEmailService()
 
     if (!instance.m_is_initialized) {
         instance.getUniqueOpId();
-        const int non_err = EMAIL_ERROR_NONE;
-
-        if(non_err != email_service_begin()){
-            LoggerE("Email service failed to begin");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Email service failed to begin");
+        
+        int ntv_ret = email_service_begin();
+        if(ntv_ret != EMAIL_ERROR_NONE){
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Email service failed to begin",
+                      ("email_service_begin error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
         }
 
-        if(non_err != email_open_db()){
-            LoggerE("Email DB failed to open");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Email DB failed to open");
+        ntv_ret = email_open_db();
+        if(ntv_ret != EMAIL_ERROR_NONE){
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Email DB failed to open",
+                      ("email_open_db error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
         }
 
         int slot_size = -1;
@@ -120,7 +123,7 @@ PlatformResult EmailManager::InitializeEmailService()
         CHECK_ERROR(ret, "create sync proxy failed");
         if (!instance.m_proxy_sync) {
             LoggerE("Sync proxy is null");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Sync proxy is null");
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Sync proxy is null");
         }
         instance.m_proxy_sync->signalSubscribe();
 
@@ -129,8 +132,7 @@ PlatformResult EmailManager::InitializeEmailService()
                                           &instance.m_proxy_load_body);
         CHECK_ERROR(ret, "create load body proxy failed");
         if (!instance.m_proxy_load_body) {
-            LoggerE("Load body proxy is null");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Load body proxy is null");
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Load body proxy is null");
         }
         instance.m_proxy_load_body->signalSubscribe();
 
@@ -147,16 +149,14 @@ PlatformResult EmailManager::InitializeEmailService()
         ret = DBus::MessageProxy::create(&instance.m_proxy_messageStorage);
         CHECK_ERROR(ret, "create message proxy failed");
         if (!instance.m_proxy_messageStorage) {
-            LoggerE("Message proxy is null");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Message proxy is null");
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Message proxy is null");
         }
         instance.m_proxy_messageStorage->signalSubscribe();
 
         ret = DBus::SendProxy::create(&instance.m_proxy_send);
         CHECK_ERROR(ret, "create send proxy failed");
         if (!instance.m_proxy_send) {
-            LoggerE("Send proxy is null");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Send proxy is null");
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Send proxy is null");
         }
         instance.m_proxy_send->signalSubscribe();
 
@@ -201,12 +201,13 @@ PlatformResult EmailManager::addMessagePlatform(int account_id,
     email_account_t* account = NULL;
     err = email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerE("email_get_account failed. [%d]\n",err);
-        err = email_free_mail_data(&mail_data,1);
-        if(EMAIL_ERROR_NONE != err) {
-            LoggerE("Failed to free mail data memory");
+        int ntv_ret = email_free_mail_data(&mail_data,1);
+        if(EMAIL_ERROR_NONE != ntv_ret) {
+            LoggerE("Failed to free mail data memory %d (%s)", ntv_ret, get_error_message(ntv_ret));
         }
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot retrieve email account information");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Cannot retrieve email account information",
+                  ("email_get_account error: %d (%s)", err, get_error_message(err)));
     }
     LoggerE("FROM %s", account->user_email_address);
     std::stringstream ss;
@@ -224,12 +225,13 @@ PlatformResult EmailManager::addMessagePlatform(int account_id,
     err = email_get_mailbox_by_mailbox_type(account_id, mailbox_type,
             &mailbox_data);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerD("email_get_mailbox_by_mailbox_type failed. [%d]\n",err);
-        err = email_free_mail_data(&mail_data,1);
-        if(EMAIL_ERROR_NONE != err) {
-            LoggerE("Failed to free mail data memory");
+        int ntv_ret = email_free_mail_data(&mail_data,1);
+        if(EMAIL_ERROR_NONE != ntv_ret) {
+            LoggerE("Failed to free mail data memory: %d (%s)", ntv_ret, get_error_message(ntv_ret));
         }
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot retrieve draft mailbox");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Cannot retrieve draft mailbox",
+                  ("email_get_mailbox_by_mailbox_type error: %d (%s)", err, get_error_message(err)));
     }
     else {
         LoggerD("email_get_mailbox_by_mailbox_type success.\n");
@@ -244,16 +246,17 @@ PlatformResult EmailManager::addMessagePlatform(int account_id,
     //adding email without attachments
     err = email_add_mail(mail_data, NULL, 0, NULL, 0);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerD("email_add_mail failed. [%d]\n",err);
-        err = email_free_mail_data(&mail_data,1);
-        if(EMAIL_ERROR_NONE != err) {
-            LoggerE("Failed to free mail data memory");
+        int ntv_ret = email_free_mail_data(&mail_data,1);
+        if(EMAIL_ERROR_NONE != ntv_ret) {
+            LoggerE("Failed to free mail data memory: %d (%s)", ntv_ret, get_error_message(ntv_ret));
         }
-        err = email_free_mailbox(&mailbox_data, 1);
-        if (EMAIL_ERROR_NONE != err) {
-            LoggerE("Failed to destroy mailbox");
+        ntv_ret = email_free_mailbox(&mailbox_data, 1);
+        if (EMAIL_ERROR_NONE != ntv_ret) {
+            LoggerE("Failed to destroy mailbox: %d (%s)", ntv_ret, get_error_message(ntv_ret));
         }
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't add message to draft mailbox");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Couldn't add message to draft mailbox",
+                  ("email_add_mail error: %d (%s)", err, get_error_message(err)));
     }
     else {
         LoggerD("email_add_mail success.\n");
@@ -271,25 +274,26 @@ PlatformResult EmailManager::addMessagePlatform(int account_id,
 
     err = email_get_mail_data(message->getId(), &mail_data_final);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerE("Failed to retrieve added mail data");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't retrieve added mail data");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Couldn't retrieve added mail data",
+                  ("email_get_mail_data error: %d (%s)", err, get_error_message(err)));
     }
     ret = message->updateEmailMessage(*mail_data_final);
     if (ret.IsError()) return ret;
 
     err = email_free_mail_data(&mail_data_final,1);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerE("Failed to free mail data final memory");
+        LoggerE("Failed to free mail data final memory: %d (%s)", err, get_error_message(err));
     }
 
     err = email_free_mail_data(&mail_data,1);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerE("Failed to free mail data memory");
+        LoggerE("Failed to free mail data memory: %d (%s)", err, get_error_message(err));
     }
 
     err = email_free_mailbox(&mailbox_data, 1);
     if (EMAIL_ERROR_NONE != err) {
-        LoggerE("Failed to destroy mailbox");
+        LoggerE("Failed to destroy mailbox: %d (%s)", err, get_error_message(err));
     }
     return PlatformResult(ErrorCode::NO_ERROR);
 }
@@ -336,7 +340,6 @@ void EmailManager::addDraftMessage(MessageCallbackUserData* callback)
     std::shared_ptr<Message> message = callback->getMessage();
     PlatformResult ret = addDraftMessagePlatform(callback->getAccountId(), message);
     if (ret.IsError()) {
-      LoggerE("%d (%s)", ret.error_code(), ret.message().c_str());
       callback->SetError(ret);
     }
   }
@@ -402,8 +405,7 @@ PlatformResult EmailManager::sendMessage(MessageRecipientsCallbackData* callback
   LoggerD("Entered");
 
   if (!callback) {
-    LoggerE("Callback is null");
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+    return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
   }
 
   int err = EMAIL_ERROR_NONE;
@@ -421,8 +423,9 @@ PlatformResult EmailManager::sendMessage(MessageRecipientsCallbackData* callback
     if (platform_result) {
       err = email_get_mail_data(message->getId(),&mail_data);
       if (EMAIL_ERROR_NONE != err) {
-        LoggerE("email_get_mail_data failed. [%d]\n", err);
-        platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get platform email structure");
+        platform_result = LogAndCreateResult(
+                              ErrorCode::UNKNOWN_ERR, "Failed to get platform email structure",
+                              ("email_get_mail_data %d (%s)", err, get_error_message(err)));
       } else {
         LoggerD("email_get_mail_data success.\n");
 
@@ -433,8 +436,9 @@ PlatformResult EmailManager::sendMessage(MessageRecipientsCallbackData* callback
         err = email_send_mail(mail_data->mail_id, &req_id);
 
         if (EMAIL_ERROR_NONE != err) {
-          LoggerE("Failed to send message %d", err);
-          platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to send message");
+          platform_result = LogAndCreateResult(
+                                ErrorCode::UNKNOWN_ERR, "Failed to send message",
+                                ("email_send_mail error: %d (%s)", err, get_error_message(err)));
         } else {
           LoggerD("req_id: %d", req_id);
           callback->getMessage()->setMessageStatus(MessageStatus::STATUS_SENDING);
@@ -444,7 +448,7 @@ PlatformResult EmailManager::sendMessage(MessageRecipientsCallbackData* callback
     }
   } else {
     LoggerE("Message is null");
-    platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Message is null");
+    platform_result = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Message is null");
   }
 
   if (!platform_result) {
@@ -496,13 +500,15 @@ void EmailManager::sendStatusCallback(int mail_id,
                 case EMAIL_ERROR_INVALID_STREAM:
                 case EMAIL_ERROR_NO_RESPONSE:
                 {
-                    LoggerE("Network error %d", error_code);
-                    callback->SetError(PlatformResult(ErrorCode::NETWORK_ERR, "Failed to send message"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::NETWORK_ERR, "Failed to send message",
+                                          ("Network error: %d (%s)", error_code, get_error_message(error_code))));
                     break;
                 }
                 default:
-                    LoggerE("Unknown error %d", error_code);
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to send message"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::UNKNOWN_ERR, "Failed to send message",
+                                          ("Unknown error: %d (%s)", error_code, get_error_message(error_code))));
                     break;
             }
         } else if (NOTI_SEND_FINISH == status) {
@@ -525,7 +531,7 @@ email_mail_data_t* EmailManager::loadMessage(int msg_id)
     email_mail_data_t* mail_data = NULL;
     int err = email_get_mail_data(msg_id, &mail_data);
     if (EMAIL_ERROR_NONE != err) {
-        LoggerE("email_get_mail_data failed. [%d]", err);
+        LoggerE("email_get_mail_data failed. [%d] (%s)", err, get_error_message(err));
     } else {
         LoggerD("email_get_mail_data success.");
     }
@@ -576,7 +582,7 @@ void EmailManager::loadMessageBody(MessageBodyCallbackData* callback)
     int op_handle = -1;
     int err = email_download_body(mailId, 0, &op_handle);
     if(EMAIL_ERROR_NONE != err){
-        LoggerE("Email download body failed, %d", err);
+        LoggerE("Email download body failed, %d (%s)", err, get_error_message(err));
         m_proxy_load_body->removeCallback(callback);
         return;
     }
@@ -588,13 +594,11 @@ PlatformResult EmailManager::loadMessageAttachment(MessageAttachmentCallbackData
   LoggerD("Entered");
 
   if (!callback) {
-    LoggerE("Callback is null");
-    return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Callback is null");
+    return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Callback is null");
   }
 
   if (!callback->getMessageAttachment()) {
-    LoggerE("Callback's message attachment is null");
-    return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Callback's message attachment is null");
+    return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Callback's message attachment is null");
   }
 
   std::shared_ptr<MessageAttachment> msgAttachment = callback->getMessageAttachment();
@@ -608,8 +612,9 @@ PlatformResult EmailManager::loadMessageAttachment(MessageAttachmentCallbackData
   };
 
   if (!mail_data) {
-    LoggerE("Couldn't get email_mail_data_t for messageId: %d", msgAttachment->getMessageId());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't load message.");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Couldn't load message.",
+              ("Couldn't get email_mail_data_t for messageId: %d", msgAttachment->getMessageId()));
   }
 
   AttachmentPtrVector attachments;
@@ -632,8 +637,9 @@ PlatformResult EmailManager::loadMessageAttachment(MessageAttachmentCallbackData
   }
 
   if (attachmentIndex < 0) {
-    LoggerE("Attachment with id: %d not found", msgAttachment->getId());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't find attachment.");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Couldn't find attachment.",
+              ("Attachment with id: %d not found", msgAttachment->getId()));
   }
 
   LoggerD("Attachment with id: [%d] is located at index: [%d]",
@@ -646,8 +652,9 @@ PlatformResult EmailManager::loadMessageAttachment(MessageAttachmentCallbackData
   int err = email_download_attachment(msgAttachment->getMessageId(), nth, &op_handle);
 
   if (EMAIL_ERROR_NONE != err) {
-    LoggerE("Download email attachment failed with error: %d", err);
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to load attachment.");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Failed to load attachment.",
+              ("Download email attachment failed with error: %d (%s)", err, get_error_message(err)));
   } else {
     LoggerD("email_download_attachment returned handle: [%d]", op_handle);
     callback->setOperationHandle(op_handle);
@@ -686,7 +693,7 @@ void EmailManager::sync(void* data)
   err = email_set_mail_slot_size(0, 0, slot_size);
 
   if (EMAIL_ERROR_NONE != err) {
-    LoggerE("Email set slot size failed, %d", err);
+    LoggerE("Email set slot size failed, %d (%s)", err, get_error_message(err));
     m_proxy_sync->removeCallback(op_id);
     return;
   }
@@ -695,7 +702,7 @@ void EmailManager::sync(void* data)
   err = email_sync_header(account_id, 0, &op_handle);
 
   if (EMAIL_ERROR_NONE != err) {
-    LoggerE("Email sync header failed, %d", err);
+    LoggerE("Email sync header failed, %d (%s)", err, get_error_message(err));
     m_proxy_sync->removeCallback(op_id);
   } else {
     callback->setOperationHandle(op_handle);
@@ -733,7 +740,7 @@ void EmailManager::syncFolder(SyncFolderCallbackData* callback)
   int err = email_get_mailbox_by_mailbox_id(folder_id, &mailbox);
 
   if (EMAIL_ERROR_NONE != err || NULL == mailbox) {
-    LoggerE("Couldn't get mailbox, error code: %d", err);
+    LoggerE("Couldn't get mailbox, error code: %d (%s)", err, get_error_message(err));
     m_proxy_sync->removeCallback(op_id);
     return;
   }
@@ -749,7 +756,7 @@ void EmailManager::syncFolder(SyncFolderCallbackData* callback)
 
   err = email_set_mail_slot_size(0, 0, slot_size);
   if (EMAIL_ERROR_NONE != err) {
-    LoggerE("Email set slot size failed, %d", err);
+    LoggerE("Email set slot size failed, %d (%s)", err, get_error_message(err));
   } else {
     int op_handle = -1;
     const int account_id = callback->getAccountId();
@@ -757,7 +764,7 @@ void EmailManager::syncFolder(SyncFolderCallbackData* callback)
     err = email_sync_header(account_id, mailbox->mailbox_id, &op_handle);
 
     if (EMAIL_ERROR_NONE != err) {
-      LoggerE("Email sync header failed, %d", err);
+      LoggerE("Email sync header failed, %d (%s)", err, get_error_message(err));
       m_proxy_sync->removeCallback(op_id);
     } else {
       callback->setOperationHandle(op_handle);
@@ -767,7 +774,7 @@ void EmailManager::syncFolder(SyncFolderCallbackData* callback)
   if (NULL != mailbox) {
     err = email_free_mailbox(&mailbox, 1);
     if (EMAIL_ERROR_NONE != err) {
-      LoggerE("Failed to email_free_mailbox - err:%d ", err);
+      LoggerE("Failed to email_free_mailbox - err: %d (%s)", err, get_error_message(err));
     }
     mailbox = NULL;
   }
@@ -793,10 +800,10 @@ void EmailManager::stopSync(long op_id)
                          EMAIL_CANCELED_BY_USER);
 
   if (EMAIL_ERROR_NONE != err) {
-    LoggerE("Email cancel job failed, %d", err);
+    LoggerE("Email cancel job failed, %d (%s)", err, get_error_message(err));
   }
 
-  callback->SetError(PlatformResult(ErrorCode::ABORT_ERR, "Sync aborted by user"));
+  callback->SetError(LogAndCreateResult(ErrorCode::ABORT_ERR, "Sync aborted by user"));
 
   callback->Post();
   m_proxy_sync->removeCallback(op_id);
@@ -877,8 +884,7 @@ void EmailManager::removeStatusCallback(const std::vector<int> &ids,
         }
         MessagesCallbackUserData* callback = it->callback;
         if (NOTI_MAIL_DELETE_FAIL == status) {
-            LoggerD("Failed to remove mail");
-            callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Messages remove failed"));
+            callback->SetError(LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Messages remove failed"));
         }
         //if one of mails failed, call error callback
         //if all mails are deleted, call success.
@@ -908,23 +914,26 @@ PlatformResult EmailManager::RemoveMessagesPlatform(MessagesCallbackUserData* ca
   MessageType type = callback->getMessageServiceType();
   for(auto it = messages.begin() ; it != messages.end(); ++it) {
     if((*it)->getType() != type) {
-      LoggerE("Invalid message type");
-      return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email");
+      return LogAndCreateResult(
+                ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email",
+                ("Invalid message type %d", (*it)->getType()));
     }
   }
   for (auto it = messages.begin() ; it != messages.end(); ++it) {
     error = email_get_mail_data((*it)->getId(), &mail);
     if (EMAIL_ERROR_NONE != error) {
-      LoggerE("Couldn't retrieve mail data");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting mail");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "Error while deleting mail",
+                ("Couldn't retrieve mail data: %d (%s)", error, get_error_message(error)));
     }
 
     //This task (_EMAIL_API_DELETE_MAIL) is for async
     error = email_delete_mail(mail->mailbox_id, &mail->mail_id, 1, 0);
     if (EMAIL_ERROR_NONE != error) {
       email_free_mail_data(&mail, 1);
-      LoggerE("Error while deleting mail");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting mail");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "Error while deleting mail",
+                ("email_delete_mail error: %d (%s)", error, get_error_message(error)));
     }
     email_free_mail_data(&mail, 1);
   }
@@ -970,8 +979,9 @@ PlatformResult EmailManager::UpdateMessagesPlatform(MessagesCallbackUserData* ca
   MessageType type = callback->getMessageServiceType();
   for (auto it = messages.begin() ; it != messages.end(); ++it) {
     if ((*it)->getType() != type) {
-      LoggerE("Invalid message type");
-      return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message");
+      return LogAndCreateResult(
+                ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message",
+                ("Invalid message type: %d", (*it)->getType()));
     }
   }
   for (auto it = messages.begin() ; it != messages.end(); ++it) {
@@ -1001,16 +1011,17 @@ PlatformResult EmailManager::UpdateMessagesPlatform(MessagesCallbackUserData* ca
       LoggerD("mail deleted = [%d]\n", mail->mail_id);
       error = email_delete_mail(mail->mailbox_id,&mail->mail_id,1,1);
       if (EMAIL_ERROR_NONE != error) {
-        LoggerE("Error while deleting old mail on update: %d", error);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Error while deleting old mail on update");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Error while deleting old mail on update",
+                  ("email_delete_mail error: %d (%s)", error, get_error_message(error)));
       }
     } else {
       LoggerD("There are no attachments, updating only email data.");
       error = email_update_mail(mail, NULL, 0, NULL, 0);
       if (EMAIL_ERROR_NONE != error) {
-        LoggerE("Error while updating mail");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while updating mail");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Error while updating mail",
+                  ("email_update_mail error: %d (%s)", error, get_error_message(error)));
       }
     }
   }
@@ -1225,8 +1236,7 @@ PlatformResult EmailManager::FindFoldersPlatform(FoldersCallbackData* callback)
 
   tizen::AbstractFilterPtr filter = callback->getFilter();
   if (!filter) {
-    LoggerE("Filter not provided");
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Filter not provided");
+    return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Filter not provided");
   }
 
   for(FilterIterator it(filter); false == it.isEnd(); it++) {
@@ -1234,8 +1244,9 @@ PlatformResult EmailManager::FindFoldersPlatform(FoldersCallbackData* callback)
     if (FIS_COMPOSITE_START == it.getState()) {
       CompositeFilterPtr cf = castToCompositeFilter((*it));
       if(cf && INTERSECTION != cf->getType()) {
-        LoggerE("[ERROR] >>> invalid Filter type: %d", cf->getType());
-        return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid Filter Type");
+        return LogAndCreateResult(
+                  ErrorCode::TYPE_MISMATCH_ERR, "Invalid Filter Type",
+                  ("Invalid Filter type: %d", cf->getType()));
       }
     }
     else if (FIS_ATTRIBUTE_FILTER == it.getState()) {
@@ -1245,9 +1256,9 @@ PlatformResult EmailManager::FindFoldersPlatform(FoldersCallbackData* callback)
         if (FIND_FOLDERS_ATTRIBUTE_ACCOUNTID_NAME == attr_name) {
           account_id = static_cast<int>(attrf->getMatchValue()->toLong());
         } else {
-          LoggerE("The attribute name: %s is invalid", attr_name.c_str());
-          return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
-                                "The attribute name is invalid");
+          return LogAndCreateResult(
+                    ErrorCode::INVALID_VALUES_ERR, "The attribute name is invalid",
+                    ("The attribute name: %s is invalid", attr_name.c_str()));
         }
       }
     }
@@ -1260,8 +1271,9 @@ PlatformResult EmailManager::FindFoldersPlatform(FoldersCallbackData* callback)
                                  &mailboxes,
                                  &mailboxes_count);
     if (EMAIL_ERROR_NONE != ret || !mailboxes) {
-      LoggerE("Cannot get folders: %d", ret);
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Platform error, cannot get folders");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "Platform error, cannot get folders",
+                ("email_get_mailbox_list error: %d (%s)", ret, get_error_message(ret)));
     }
 
     if (mailboxes_count <= 0) {
@@ -1335,9 +1347,9 @@ PlatformResult EmailManager::RemoveConversationsPlatform(ConversationCallbackDat
   int thread_id = 0;
   for(auto it = conversations.begin() ; it != conversations.end(); ++it) {
     if ((*it)->getType() != type) {
-      LoggerE("Invalid message type");
-      return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
-                            "Error while deleting email conversation");
+      return LogAndCreateResult(
+                ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email conversation",
+                ("Invalid message type %d", (*it)->getType()));
     }
   }
 
@@ -1345,9 +1357,9 @@ PlatformResult EmailManager::RemoveConversationsPlatform(ConversationCallbackDat
     thread_id = (*it)->getConversationId();
     error = email_delete_thread(thread_id, false);
     if (EMAIL_ERROR_NONE != error) {
-      LoggerE("Couldn't delete email conversation data");
-      return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
-                            "Error while deleting email conversation");
+      return LogAndCreateResult(
+                ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email conversation",
+                ("Couldn't delete email conversation data %d (%s)", error, get_error_message(error)));
     }
 
     // for now, there is no way to recognize deleting email thread job is completed.
@@ -1406,7 +1418,7 @@ std::string EmailManager::getMessageStatus(int id) {
 
   int ret = email_get_mail_data(id, &mail);
   if (EMAIL_ERROR_NONE != ret ) {
-    LoggerD("Failed to get data.");
+    LoggerD("Failed to get data %d (%s)", ret, get_error_message(ret));
     return "";
   }
 
@@ -1430,7 +1442,7 @@ std::string EmailManager::getMessageStatus(int id) {
 
   ret = email_free_mail_data(&mail, 1);
   if (EMAIL_ERROR_NONE != ret ) {
-    LoggerD("Failed to free mail data.");
+    LoggerD("Failed to free mail data %d (%s)", ret, get_error_message(ret));
   }
 
   return MessagingUtil::messageStatusToString(status);
index fd03ad01ee0dca63ef2977d0778624e387e75803..d3d086db3139a19ee475b7ef809bf2c453f05209 100755 (executable)
@@ -394,14 +394,12 @@ PlatformResult saveToTempFile(const std::string &data, std::string* file_name)
     umask(old_mask);
 
     if (NULL == file) {
-        LoggerE("Failed to create file");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to create file");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to create file");
     }
     if (fprintf(file, "%s", data.c_str()) < 0) {
-        LoggerE("Failed to write data into file");
         fclose(file);
         remove(tmp_name.c_str());
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to write data into file");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to write data into file");
     }
     fflush(file);
     fclose(file);
@@ -433,7 +431,8 @@ PlatformResult copyFileToTemp(const std::string& sourcePath, std::string* result
     // Looking for the last occurrence of slash in source path
     std::size_t slashPos;
     if ((slashPos = attPath.find_last_of('/')) == std::string::npos) {
-      return PlatformResult(ErrorCode::UNKNOWN_ERR,
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR,
                 "Error while copying file to temp: the source path is invalid.");
     }
 
@@ -442,8 +441,8 @@ PlatformResult copyFileToTemp(const std::string& sourcePath, std::string* result
 
     LoggerD("attPath: %s, tmpPath: %s", attPath.c_str(), tmpPath.c_str());
     if(EINA_TRUE != ecore_file_mkdir(dirPath.c_str())) {
-      return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                            "Unknown error while creating temp directory.");
+      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+                                "Unknown error while creating temp directory.");
     }
 
     FILE *f1, *f2;
@@ -452,14 +451,12 @@ PlatformResult copyFileToTemp(const std::string& sourcePath, std::string* result
 
     f1 = fopen(attPath.c_str(), "rb");
     if (!f1) {
-        LoggerE("Fail open attPath");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Fail open attPath");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail open attPath");
     }
     f2 = fopen(tmpPath.c_str(), "wb");
     if (!f2) {
-        LoggerE("Fail open tmpPath");
         fclose (f1);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Fail open tmpPath");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail open tmpPath");
     }
 
     while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) {
@@ -471,8 +468,8 @@ PlatformResult copyFileToTemp(const std::string& sourcePath, std::string* result
     fclose (f2);
 
     if(EINA_TRUE != ret /*ecore_file_cp(attPath.c_str(), tmpPath.c_str())*/) {
-        std::string error = "Unknown error while copying file to temp. ";
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, error.c_str());
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+                                  "Unknown error while copying file to temp.");
     }
 
     *result_path = dirPath;
@@ -483,7 +480,8 @@ PlatformResult removeDirFromTemp(const std::string& dirPath)
 {
     LoggerD("Entered");
     if(EINA_TRUE != ecore_file_recursive_rm(dirPath.c_str())) {
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error while deleting temp directory.");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "Unknown error while deleting temp directory.");
     }
     return PlatformResult(ErrorCode::NO_ERROR);
 }
@@ -494,8 +492,7 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr<Message> message,
     LoggerD("Entered");
     email_mail_data_t* mail_data = nullptr;
     if(EMAIL != message->getType()) {
-        LoggerE("Invalid type");
-        return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid type.");
+        return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Invalid type.");
     }
 
     if(message->is_id_set()) {
@@ -503,8 +500,7 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr<Message> message,
     } else {
         mail_data = (email_mail_data_t*)malloc(sizeof(email_mail_data_t));
         if (!mail_data) {
-          LoggerE("malloc failure");
-          return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to allocate memory.");
+          return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to allocate memory.");
         }
         memset(mail_data, 0x00, sizeof(email_mail_data_t));
     }
@@ -548,8 +544,7 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr<Message> message,
             mail_data->file_path_plain = strdup(body_file_path.c_str());
             if(!mail_data->file_path_plain)
             {
-                LoggerE("Plain Body file is NULL.");
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
+                return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
             }
         }
 
@@ -559,8 +554,7 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr<Message> message,
             mail_data->file_path_html = strdup(html_file_path.c_str());
             if(!mail_data->file_path_html)
             {
-                LoggerE("Html Body file is NULL.");
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "Html Body file is NULL.");
+                return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Html Body file is NULL.");
             }
         } else if(!body->getPlainBody().empty()) {
             // check html data is exist if not exist copy plain body to html body
@@ -569,8 +563,7 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr<Message> message,
             mail_data->file_path_html = strdup(html_file_path.c_str());
             if(!mail_data->file_path_html)
             {
-                LoggerE("Plain Body file is NULL.");
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
+                return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
             }
         }
     }
@@ -608,19 +601,20 @@ PlatformResult addSingleEmailAttachment(std::shared_ptr<Message> message,
     int id = message->getId();
     int err = email_add_attachment(id, tmp);
     if(EMAIL_ERROR_NONE != err) {
-        LoggerE("Error while adding attachment %d", err);
-        err = email_free_attachment_data(&tmp, 1);
-        if (EMAIL_ERROR_NONE != err) {
-            LoggerW("Failed to free attachment data");
+        int ntv_ret = email_free_attachment_data(&tmp, 1);
+        if (EMAIL_ERROR_NONE != ntv_ret) {
+            LoggerW("Failed to free attachment data: %d (%s)", ntv_ret, get_error_message(ntv_ret));
         }
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error while adding attachment");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Unknown error while adding attachment",
+                  ("email_add_attachment error: %d (%s)", err, get_error_message(err)));
     }
 
     att->setId(tmp->attachment_id);
     att->setMessageId(id);
     err = email_free_attachment_data(&tmp, 1);
     if (EMAIL_ERROR_NONE != err) {
-        LoggerW("Failed to free attachment data");
+        LoggerW("Failed to free attachment data %d (%s)", err, get_error_message(err));
     }
 
     return removeDirFromTemp(dirPath);
@@ -664,9 +658,11 @@ PlatformResult Message::addEmailAttachments(std::shared_ptr<Message> message)
     if (EMAIL_ERROR_NONE != error) {
         email_free_mail_data(&mail, 1);
         email_free_attachment_data(&attachment_data_list,attachment_data_count);
-        LoggerE("Error while adding attachments. Failed to get attachment list.");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Error while adding attachments. Failed to get attachment list.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR,
+                  "Error while adding attachments. Failed to get attachment list.",
+                  ("Error %d while adding attachments. Failed to get attachment list. (%s)",
+                      error, get_error_message(error)));
     }
 
     //save mail without attachments id
@@ -677,8 +673,9 @@ PlatformResult Message::addEmailAttachments(std::shared_ptr<Message> message)
     if (EMAIL_ERROR_NONE != error) {
         email_free_mail_data(&mail, 1);
         email_free_attachment_data(&attachment_data_list,attachment_data_count);
-        LoggerE("Error while re-adding mail: %d", error);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while re-adding mail");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Error while re-adding mail",
+                  ("Error %d while re-adding mail (%s)", error, get_error_message(error)));
     }
     LoggerD("mail added - new id = [%d]\n", mail->mail_id);
 
@@ -697,8 +694,9 @@ PlatformResult Message::addEmailAttachments(std::shared_ptr<Message> message)
     error = email_delete_mail(mail->mailbox_id,&tmp_id,1,1);
     if (EMAIL_ERROR_NONE != error) {
         email_free_mail_data(&mail, 1);
-        LoggerE("Error while deleting mail from server: %d", error);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting mail from server");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Error while deleting mail from server",
+                  ("email_delete_mail error: %d (%s)", error, get_error_message(error)));
     }
     email_free_mail_data(&mail, 1);
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -724,8 +722,9 @@ PlatformResult Message::addSMSRecipientsToStruct(const std::vector<std::string>
                     address, strlen(address));
         }
         else {
-            LoggerE("failed to add address[%d] %s", i, address);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add address");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "failed to add address",
+                      ("failed to add address[%d] %s", i, address));
         }
     }
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -758,8 +757,9 @@ PlatformResult Message::addMMSRecipientsToStruct(const std::vector<std::string>
                     address, strlen(address));
         }
         else {
-            LoggerE("[%d] failed to add address: [%s], error: %d", i, address, error);
-            return PlatformResult (ErrorCode::UNKNOWN_ERR, "failed to add address");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "failed to add address",
+                      ("[%d] failed to add address: [%s], error: %d", i, address, error));
         }
     }
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -822,8 +822,9 @@ PlatformResult Message::addMMSBodyAndAttachmentsToStruct(const AttachmentPtrVect
                     attach.at(i)->getMimeType().c_str());
             }
         } else {
-            LoggerE("att[%d]: failed to add attachment");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add attachment");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "failed to add attachment",
+                      ("att[%d]: failed to add attachment"));
         }
     }
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -834,9 +835,12 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
 {
     LoggerD("Entered");
 
+    int ntv_ret = 0;
+
     if (message->getType() != SMS && message->getType() != MMS) {
-        LoggerD("Invalid type");
-        return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid type");
+        return LogAndCreateResult(
+                  ErrorCode::INVALID_VALUES_ERR, "Invalid type",
+                  ("Invalid type: %d", message->getType()));
     }
 
     msg_error_t err = MSG_SUCCESS;
@@ -850,25 +854,28 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
         std::unique_ptr<msg_struct_t, int (*)(msg_struct_t*)> send_opt_ptr(&send_opt, msg_release_struct);
         err = msg_get_message(handle, id, msg, send_opt);
         if (err != MSG_SUCCESS) {
-            LoggerD("msg_get_message() Fail [%d]", err);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "msg_get_message() Fail");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "msg_get_message() Fail",
+                      ("msg_get_message() Fail [%d] (%s)", err, get_error_message(err)));
         }
         LoggerD("Using existing msg for id: %d", id);
     } else { // id is not set - the message does not exist in database
         MessageType msgType = message->getType();
         if (msgType == MessageType::SMS) {
             // Set message type to SMS
-            if (MSG_SUCCESS
-                    != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS)) {
-                LoggerE("Set SMS type error");
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set SMS type error");
+            ntv_ret = msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS);
+            if (MSG_SUCCESS != ntv_ret) {
+                return LogAndCreateResult(
+                          ErrorCode::UNKNOWN_ERR, "Set SMS type error",
+                          ("msg_set_int_value error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
             }
         } else {
             // Set message type to MMS
-            if (MSG_SUCCESS
-                    != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)) {
-                LoggerE("Set MMS type error");
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS type error");
+            ntv_ret = msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
+            if (MSG_SUCCESS != ntv_ret) {
+                return LogAndCreateResult(
+                          ErrorCode::UNKNOWN_ERR, "Set MMS type error",
+                          ("msg_set_int_value error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
             }
         }
     }
@@ -889,8 +896,9 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
         // Reset SMS recipients
         int error = msg_list_clear(msg, MSG_MESSAGE_ADDR_LIST_HND);
         if( MSG_SUCCESS != error) {
-            LoggerE("Failed to clear address list, error: %d", error);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to clear address list");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Failed to clear address list",
+                      ("msg_list_clear error: %d (%s)", error, get_error_message(error)));
         }
 
         // Set SMS recipients
@@ -902,26 +910,29 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
 
     } else if (type == MSG_TYPE_MMS) {
         // Set message type to MMS
-        if (MSG_SUCCESS
-                != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)) {
-            LoggerE("Message(%p): Set MMS type error", message);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS type error");
+        ntv_ret = msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
+        if (MSG_SUCCESS != ntv_ret) {
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Set MMS type error",
+                      ("Message(%p): Set MMS type error %d (%s)", message, ntv_ret, get_error_message(ntv_ret)));
         }
         // Create MMS data
         msg_struct_t mms_data = msg_create_struct(MSG_STRUCT_MMS);
         if (mms_data == NULL) {
-            LoggerE("Message(%p): Set MMS data error", message);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS data error");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Set MMS data error",
+                      ("Message(%p): Set MMS data error", message));
         } else {
             std::unique_ptr<msg_struct_t, int (*)(msg_struct_t*)> mms_data_ptr(&mms_data, msg_release_struct);
             // Set MMS message subject
             std::string subject = message->getSubject();
             if (subject != "") {
-                int r = msg_set_str_value(msg, MSG_MESSAGE_SUBJECT_STR,
-                        const_cast<char*>(subject.c_str()), subject.size());
-                if (r != MSG_SUCCESS) {
-                    LoggerE("Message(%p): Set MMS subject error: %d", message, r);
-                    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS subject error");
+                ntv_ret = msg_set_str_value(msg, MSG_MESSAGE_SUBJECT_STR,
+                          const_cast<char*>(subject.c_str()), subject.size());
+                if (ntv_ret != MSG_SUCCESS) {
+                    return LogAndCreateResult(
+                              ErrorCode::UNKNOWN_ERR, "Set MMS subject error",
+                              ("Message(%p): Set MMS subject error: %d (%s)", message, ntv_ret, get_error_message(ntv_ret)));
                 }
             }
             // Set MMS message text
@@ -977,8 +988,10 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
                         const_cast<char*>(body_file_path.c_str()),
                         body_file_path.size());
                 if (error != MSG_SUCCESS) {
-                    LoggerE("Message(%p): Failed to set mms body filepath", message);
-                    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to set mms body filepath");
+                    return LogAndCreateResult(
+                              ErrorCode::UNKNOWN_ERR, "Failed to set mms body filepath",
+                              ("Message(%p): Failed to set mms body filepath %d (%s)",
+                                  message, error, get_error_message(error)));
                 }
                 msg_set_str_value(media, MSG_MMS_MEDIA_CONTENT_TYPE_STR,
                                   const_cast<char*>("text/plain"), 10);
@@ -1007,10 +1020,12 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
                 if (ret.IsError()) return ret;
             }
             // Set MMS body
-            int r = msg_set_mms_struct(msg, mms_data);
-            if (r != MSG_SUCCESS) {
-                LoggerE("Message(%p): Set MMS body error: %d", message, r);
-                return PlatformResult (ErrorCode::UNKNOWN_ERR, "Set MMS body error");
+            ntv_ret = msg_set_mms_struct(msg, mms_data);
+            if (ntv_ret != MSG_SUCCESS) {
+                return LogAndCreateResult(
+                          ErrorCode::UNKNOWN_ERR, "Set MMS body error",
+                          ("Message(%p): Set MMS body error: %d (%s)",
+                              message, ntv_ret, get_error_message(ntv_ret)));
             }
         }
 
@@ -1030,8 +1045,9 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
         if (ret.IsError()) return ret;
     }
     else {
-        LoggerE("Message(%p): Invalid message type", message);
-        return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid message type");
+        return LogAndCreateResult(
+                  ErrorCode::INVALID_VALUES_ERR, "Invalid message type",
+                  ("Message(%p): Invalid message type", message));
     }
 
     // set common attributes for SMS and MMS
@@ -1061,11 +1077,11 @@ PlatformResult Message::convertPlatformShortMessageToStruct(Message* message,
     // -1 means unknown - so do not set simindex in that case.
     int sim_index = static_cast<int>(message->getSimIndex());
     if (sim_index != -1) {
-        int error =
-            msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, sim_index+1);
-        if ( MSG_SUCCESS != error) {
-            LoggerE("Failed to set sim index, error: %d", error);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to set sim index");
+        int error = msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, sim_index+1);
+        if (MSG_SUCCESS != error) {
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Failed to set sim index",
+                      ("msg_set_int_value error: %d (%s)", error, get_error_message(error)));
         }
     }
 
@@ -1119,9 +1135,8 @@ PlatformResult Message::getSMSRecipientsFromStruct(msg_struct_t &msg,
     LoggerD("Entered");
     std::vector<std::string> address;
     msg_list_handle_t addr_list = NULL;
-    if (MSG_SUCCESS
-            == msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND,
-                    (void **) &addr_list)) {
+    int ntv_ret = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **) &addr_list);
+    if (MSG_SUCCESS == ntv_ret) {
         int size = msg_list_length(addr_list);
         for (int i = 0; i < size; i++) {
             msg_struct_t addr_info = NULL;
@@ -1133,8 +1148,10 @@ PlatformResult Message::getSMSRecipientsFromStruct(msg_struct_t &msg,
             address.push_back(std::string(infoStr));
         }
     } else {
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "failed to add recipients",
+                  ("msg_get_list_handle error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
         LoggerE("failed to get recipients");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add recipients");
     }
     *result_address = address;
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -1146,9 +1163,8 @@ PlatformResult Message::getMMSRecipientsFromStruct(msg_struct_t &msg,
     LoggerD("Entered");
     std::vector<std::string> address;
     msg_list_handle_t addr_list = NULL;
-    if (MSG_SUCCESS
-            == msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND,
-                    (void **) &addr_list)) {
+    int ntv_ret = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **) &addr_list);
+    if (MSG_SUCCESS == ntv_ret) {
         int size = msg_list_length(addr_list);
         for (int i = 0; i < size; i++) {
             msg_struct_t addr_info = NULL;
@@ -1165,8 +1181,9 @@ PlatformResult Message::getMMSRecipientsFromStruct(msg_struct_t &msg,
             }
         }
     } else {
-        LoggerE("failed to get recipients");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add recipients");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "failed to add recipients",
+                  ("msg_get_list_handle error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
     }
     *result_address = address;
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -1182,9 +1199,10 @@ PlatformResult Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
     msg_struct_t mms_struct = msg_create_struct(MSG_STRUCT_MMS);
     int error = msg_get_mms_struct(msg, mms_struct);
     if (MSG_SUCCESS != error) {
-        LoggerE("Cannot get mms struct, error:%d", error);
         msg_release_struct(&mms_struct);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "cannot get mms struct");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "cannot get mms struct",
+                  ("msg_get_mms_struct error: %d (%s)", error, get_error_message(error)));
     }
 
     bool body_has_been_set = false;
@@ -1276,15 +1294,17 @@ PlatformResult Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
                 }
             } else {
                 msg_release_struct(&mms_struct);
-                LoggerE("failed to get attachment");
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to get attachment");
+                return LogAndCreateResult(
+                          ErrorCode::UNKNOWN_ERR, "failed to get attachment",
+                          ("msg_get_list_handle error: %d (%s)", error, get_error_message(error)));
             }
             msg_release_struct(&page);
         }
     } else {
         msg_release_struct(&mms_struct);
-        LoggerE("failed to get attachment");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to get attachment");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "failed to get attachment",
+                  ("msg_get_list_handle error: %d (%s)", error, get_error_message(error)));
     }
 
     if(false == body_has_been_set) {
@@ -1341,8 +1361,9 @@ PlatformResult Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
         }
     } else {
         msg_release_struct(&mms_struct);
-        LoggerE("failed to get attachment");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add attachment");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "failed to add attachment",
+                  ("msg_get_list_handle error: %d (%s)", error, get_error_message(error)));
     }
 
     LoggerD("after MSG_MMS_ATTACH_LIST attachments count is:%d",
@@ -1371,7 +1392,7 @@ PlatformResult Message::convertPlatformShortMessageToObject(msg_struct_t msg, Me
         std::vector<std::string> recp_list;
         PlatformResult ret = message->getSMSRecipientsFromStruct(msg, &recp_list);
         if (ret.IsError()) {
-          LoggerE("failed to get SMS recipients from struct");
+          LoggerE("failed to get SMS recipients from struct (%s)", ret.message().c_str());
           return ret;
         }
 
@@ -1445,8 +1466,9 @@ PlatformResult Message::convertPlatformShortMessageToObject(msg_struct_t msg, Me
           return ret;
         }
     } else {
-        LoggerE("Invalid Message type: %d", infoInt);
-        return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid Message type");
+        return LogAndCreateResult(
+                  ErrorCode::INVALID_VALUES_ERR, "Invalid Message type",
+                  ("Invalid Message type: %d", infoInt));
     }
 
     // get id
@@ -1602,9 +1624,14 @@ PlatformResult Message::convertEmailToMessageAttachment(email_mail_data_t& mail,
   email_attachment_data_t* attachment = NULL;
   int attachmentCount = 0;
 
-  if (EMAIL_ERROR_NONE != email_get_attachment_data_list(mail.mail_id,
-                                                         &attachment, &attachmentCount)) {
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.");
+  int ntv_ret = email_get_attachment_data_list(
+                    mail.mail_id,
+                    &attachment,
+                    &attachmentCount);
+  if (EMAIL_ERROR_NONE != ntv_ret) {
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.",
+              ("email_get_attachment_data_list error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
   }
   if ( attachment && attachmentCount > 0) {
     for (int i = 0; i < attachmentCount; i++) {
@@ -1634,9 +1661,8 @@ PlatformResult Message::convertPlatformEmailToObject(
 
 PlatformResult Message::updateEmailMessage(email_mail_data_t& mail)
 {
-    LoggerW("This should be called on MessageEmail instance");
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR,
-                          "This should be called on MessageEmail instance");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+                              "This should be called on MessageEmail instance");
 }
 
 /**
index 9c843f72fabfbeb396be7d7d861c1eb9156ea819..50181e8ebd4671c141e54ccc31cdca6335f16116 100755 (executable)
@@ -120,9 +120,9 @@ PlatformResult MessageBody::updateBody(email_mail_data_t& mail)
       PlatformResult ret = MessagingUtil::loadFileContentToString(mail.file_path_plain,
                                                                   &result);
       if (ret.IsError()) {
-        LoggerE("Fail to open plain body.");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Fail to open plain body.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Fail to open plain body.",
+                  ("%s", ret.message().c_str()));
       }
       setPlainBody(result);
     }
@@ -133,9 +133,9 @@ PlatformResult MessageBody::updateBody(email_mail_data_t& mail)
       PlatformResult ret = MessagingUtil::loadFileContentToString(mail.file_path_html,
                                                                   &result);
       if (ret.IsError()) {
-        LoggerE("Fail to open html body.");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Fail to open html body.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Fail to open html body.",
+                  ("%s", ret.message().c_str()));
       }
       setHtmlBody(result);
     }
index eb26e3b7674752b8c3ab57453471777bfcd872b6..a02b8e6ec00c00898a3892e1dc6bdc752d3503cd 100755 (executable)
@@ -157,8 +157,9 @@ PlatformResult MessageConversation::convertMsgConversationToObject(
     msg_error_t err = msg_get_thread(handle, conversation->m_conversation_id, msg_thread);
     if (err != MSG_SUCCESS)
     {
-      LoggerE("Failed to retrieve thread.");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to retrieve thread.");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "Failed to retrieve thread.",
+                ("msg_get_thread error: %d (%s)", err, get_error_message(err)));
     }
     msg_get_int_value(msg_thread, MSG_THREAD_MSG_TYPE_INT, &tempInt);
     switch(tempInt)
@@ -196,8 +197,9 @@ PlatformResult MessageConversation::convertMsgConversationToObject(
         // automatically release the memory
     if (err != MSG_SUCCESS)
     {
-      LoggerE("Get conversation(msg) view list fail.");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get conversation(msg) view list fail.");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "Get conversation(msg) view list fail.",
+                ("msg_get_conversation_view_list error: %d (%s)", err, get_error_message(err)));
     }
 
     lastMsgIndex = convViewList.nCount - 1;
@@ -209,11 +211,12 @@ PlatformResult MessageConversation::convertMsgConversationToObject(
     msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_ID_INT, &tempInt);
     conversation->m_last_message_id = tempInt;
 
-    if (msg_get_message(handle, conversation->m_last_message_id, msgInfo,
-                        sendOpt) != MSG_SUCCESS)
+    err = msg_get_message(handle, conversation->m_last_message_id, msgInfo, sendOpt);
+    if (err != MSG_SUCCESS)
     {
-      LoggerE("Get message fail.");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "get message fail.");
+      return LogAndCreateResult(
+                ErrorCode::UNKNOWN_ERR, "get message fail.",
+                ("msg_get_message error: %d (%s)", err, get_error_message(err)));
     }
 
     msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_DIRECTION_INT, &tempInt);
@@ -279,7 +282,8 @@ PlatformResult MessageConversation::convertEmailConversationToObject(
 
     email_mail_list_item_t *resultMail = NULL;
 
-    if(email_get_thread_information_ex(threadId, &resultMail) != EMAIL_ERROR_NONE)
+    int ntv_ret = email_get_thread_information_ex(threadId, &resultMail);
+    if(ntv_ret != EMAIL_ERROR_NONE)
     {
         if (resultMail)
         {
@@ -290,27 +294,31 @@ PlatformResult MessageConversation::convertEmailConversationToObject(
             free(resultMail);
         }
 
-        LoggerE("Couldn't get conversation");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't get conversation.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Couldn't get conversation.",
+                  ("email_get_thread_information_ex error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
     } else {
         if (!resultMail)
         {
-            LoggerE("Data is null");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Get email data fail.",
+                      ("Data is null"));
         }
 
         email_mail_data_t* mailData = NULL;
 
-        if (email_get_mail_data(resultMail->mail_id,
-                &mailData) != EMAIL_ERROR_NONE)
+        ntv_ret = email_get_mail_data(resultMail->mail_id, &mailData);
+        if (ntv_ret != EMAIL_ERROR_NONE)
         {
             free(resultMail);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Get email data fail.",
+                      ("email_get_mail_data error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
         }
 
         if (!mailData) {
             free(resultMail);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
         }
 
         int index = 0;
@@ -318,13 +326,17 @@ PlatformResult MessageConversation::convertEmailConversationToObject(
         conversation->m_unread_messages = 0;
         email_mail_list_item_t *mailList = NULL;
 
-        if (email_get_mail_list(mailData->account_id, 0, threadId, 0,
-            resultMail->thread_item_count, EMAIL_SORT_DATETIME_HIGH, &mailList,
-            &count) != EMAIL_ERROR_NONE)
+        ntv_ret = email_get_mail_list(
+                      mailData->account_id, 0, threadId, 0,
+                      resultMail->thread_item_count, EMAIL_SORT_DATETIME_HIGH, &mailList,
+                      &count);
+        if (ntv_ret != EMAIL_ERROR_NONE)
         {
             email_free_mail_data(&mailData , 1);
             free(resultMail);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data list fail.");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "Get email data list fail.",
+                      ("email_get_mail_list error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
         }
 
         for (index = 0; index < count; index++)
index f420ccceb9be150174a0f942b9b74df12ee5ec54..cc3a8afa2b3df872d7006d750ed849a223e802fa 100755 (executable)
@@ -101,8 +101,9 @@ bool MessageRecipientsCallbackData::setSimIndex(
 
     sim_index--;
     if (sim_index >= sim_count || sim_index < -1) {
-        LoggerE("Sim index out of bound %d : %d", sim_index, sim_count);
-        this->SetError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound"));
+        this->SetError(LogAndCreateResult(
+                          ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound",
+                          ("Sim index out of bound %d : %d", sim_index, sim_count)));
         return false;
     }
 
@@ -350,52 +351,48 @@ MessageStoragePtr MessageService::getMsgStorage() const
 common::PlatformResult MessageService::sendMessage(MessageRecipientsCallbackData *callback)
 {
     // this method should be overwritten be specific services
-    LoggerE("Cannot send message");
     delete callback;
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Unable to send message.");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Unable to send message.");
 }
 
 PlatformResult MessageService::loadMessageBody(MessageBodyCallbackData* callback)
 {
     // this method should be overwritten by specific services
-    LoggerE("Cannot load message body");
     delete callback;
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message body");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message body");
 }
 
 PlatformResult MessageService::loadMessageAttachment(MessageAttachmentCallbackData* callback)
 {
     // this method should be overwritten by email service
     // for MMS and SMS this function is not supported
-    LoggerE("Cannot load message attachment");
     delete callback;
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message attachment");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message attachment");
 }
 
 PlatformResult MessageService::sync(SyncCallbackData *callback, long* operation_id)
 {
     // this method should be overwritten by email service
     // for MMS and SMS this function is not supported
-    LoggerE("Cannot sync with external server");
     delete callback;
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot sync with external server");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot sync with external server");
 }
 
 PlatformResult MessageService::syncFolder(SyncFolderCallbackData *callback, long* operation_id)
 {
     // this method should be overwritten by email service
     // for MMS and SMS this function is not supported
-    LoggerE("Cannot sync folder with external server");
     delete callback;
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot sync folder with external server");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+                              "Cannot sync folder with external server");
 }
 
 PlatformResult MessageService::stopSync(long op_id)
 {
     // this method should be overwritten by email service
     // for MMS and SMS this function is not supported
-    LoggerE("Cannot stop sync with external server");
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot stop sync with external server");
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+                              "Cannot stop sync with external server");
 }
 
 } // messaging
index cfee4b67c3cc4d5e2620729ab59c4d79e2df8aea..34c2f6dffcb958febd3a01a4faf4e8116b49f355 100755 (executable)
@@ -61,17 +61,17 @@ PlatformResult MessageServiceEmail::sendMessage(MessageRecipientsCallbackData *c
     LoggerD("Entered");
 
     if (!callback) {
-        LoggerE("Callback is null");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
     }
 
     callback->setAccountId(m_id);
 
     guint id = g_idle_add(sendMessageTask, static_cast<void*>(callback));
     if (!id) {
-        LoggerE("g_idle_add fails");
         delete callback;
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Could not add task",
+                  ("g_idle_add fails"));
     }
 
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -90,15 +90,15 @@ PlatformResult MessageServiceEmail::loadMessageBody(MessageBodyCallbackData* cal
 {
     LoggerD("Entered");
     if (!callback) {
-        LoggerE("Callback is null");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
     }
 
     guint id = g_idle_add(loadMessageBodyTask, static_cast<void*>(callback));
     if (!id) {
-        LoggerE("g_idle_add failed");
         delete callback;
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Could not add task",
+                  ("g_idle_add failed"));
     }
 
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -142,9 +142,10 @@ PlatformResult MessageServiceEmail::loadMessageAttachment(MessageAttachmentCallb
   LoggerD("Entered");
   guint id = g_idle_add(loadMessageAttachmentTask, static_cast<void*>(callback));
   if (!id) {
-    LoggerE("g_idle_add failed");
     delete callback;
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Could not add task",
+              ("g_idle_add failed"));
   }
   return PlatformResult(ErrorCode::NO_ERROR);
 }
@@ -163,8 +164,7 @@ PlatformResult MessageServiceEmail::sync(SyncCallbackData *callback, long* opera
   LoggerD("Entered");
 
   if (!callback) {
-    LoggerE("Callback is null");
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+    return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
   }
 
   long op_id = EmailManager::getInstance().getUniqueOpId();
@@ -172,9 +172,10 @@ PlatformResult MessageServiceEmail::sync(SyncCallbackData *callback, long* opera
 
   guint id = g_idle_add(syncTask, static_cast<void*>(callback));
   if (!id) {
-    LoggerE("g_idle_add failed");
     delete callback;
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Could not add task",
+              ("g_idle_add failed"));
   }
   *operation_id = op_id;
   registered_callbacks_.insert(op_id);
@@ -194,14 +195,12 @@ PlatformResult MessageServiceEmail::syncFolder(SyncFolderCallbackData *callback,
 {
   LoggerD("Entered");
   if (!callback) {
-    LoggerE("Callback is null");
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+    return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
   }
 
   if (!callback->getMessageFolder()) {
-    LoggerE("Message folder is null");
     delete callback;
-    return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Message folder is null");
+    return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, "Message folder is null");
   }
 
   long op_id = EmailManager::getInstance().getUniqueOpId();
@@ -209,9 +208,10 @@ PlatformResult MessageServiceEmail::syncFolder(SyncFolderCallbackData *callback,
 
   guint id = g_idle_add(syncFolderTask, callback);
   if (!id) {
-    LoggerE("g_idle_add fails");
     delete callback;
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Could not add task",
+              ("g_idle_add fails"));
   }
   *operation_id = op_id;
   registered_callbacks_.insert(op_id);
@@ -244,10 +244,11 @@ PlatformResult MessageServiceEmail::stopSync(long op_id)
   guint id = g_idle_add(stopSyncTask, static_cast<void*>(data));
 
   if (!id) {
-    LoggerE("g_idle_add failed");
     delete data;
     data = NULL;
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+    return LogAndCreateResult(
+              ErrorCode::UNKNOWN_ERR, "Could not add task",
+              ("g_idle_add failed"));
   }
   return PlatformResult(ErrorCode::NO_ERROR);
 }
index 32b800f99e82cf1c47135858793fdd6704fcb052..3d0cd75392d03c965c92ff8df271bbfbc0513729 100755 (executable)
@@ -67,8 +67,7 @@ PlatformResult MessageServiceShortMsg::sendMessage(MessageRecipientsCallbackData
 {
     LoggerD("Entered");
     if (!callback) {
-        LoggerE("Callback is null");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
     }
 
     /*
@@ -107,9 +106,10 @@ PlatformResult MessageServiceShortMsg::sendMessage(MessageRecipientsCallbackData
         }
 
         if (sim_index >= sim_count) {
-            LoggerE("Sim index out of count %d : %d", sim_index, sim_count);
             delete callback;
-            return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound");
+            return LogAndCreateResult(
+                      ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound",
+                      ("Sim index out of count %d : %d", sim_index, sim_count));
         }
 
         callback->getMessage()->setSimIndex(sim_index);
@@ -118,9 +118,10 @@ PlatformResult MessageServiceShortMsg::sendMessage(MessageRecipientsCallbackData
     }
 
     if(!g_idle_add(sendMessageThread, static_cast<void*>(callback))) {
-        LoggerE("g_idle_add fails");
         delete callback;
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Could not add task",
+                  ("g_idle_add fails"));
     }
 
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -149,15 +150,15 @@ PlatformResult MessageServiceShortMsg::loadMessageBody(MessageBodyCallbackData *
 {
     LoggerD("Entered");
     if (!callback) {
-        LoggerE("Callback is null");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
     }
 
     guint id = g_idle_add(loadMessageBodyTask, static_cast<void*>(callback));
     if (!id) {
-        LoggerE("g_idle_add fails");
         delete callback;
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Could not add task",
+                  ("g_idle_add fails"));
     }
 
     return PlatformResult(ErrorCode::NO_ERROR);
index 74cdacc315e867c5c9c3914d18fdc6308c2a3831..b4ff9c1861584e4aa22046522b6c9b208ebd19ef 100755 (executable)
@@ -365,9 +365,9 @@ PlatformResult MessagingDatabaseManager::getAttributeFilterQuery(AbstractFilterP
     std::ostringstream sqlQuery;
     AttributeFilterPtr attr_filter = castToAttributeFilter(filter);
     if(!attr_filter) {
-        LoggerE("passed filter is not valid AttributeFilter!");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Wrong filter type - not attribute filter");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+                                  "Wrong filter type - not attribute filter",
+                                  ("passed filter is not valid AttributeFilter!"));
     }
 
     const std::string attribute_name = attr_filter->getAttributeName();
@@ -376,9 +376,9 @@ PlatformResult MessagingDatabaseManager::getAttributeFilterQuery(AbstractFilterP
     if (it != attribute_map.end()) {
         sqlQuery << "(" << attribute_map[attribute_name].sql_name << " ";
     } else {
-        LoggerE("The attribute: %s does not exist.", attribute_name.c_str());
-        return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
-                              "The attribute does not exist.");
+        return LogAndCreateResult(
+                  ErrorCode::INVALID_VALUES_ERR, "The attribute does not exist.",
+                  ("The attribute: %s does not exist.", attribute_name.c_str()));
     }
 
     AnyPtr match_value_any_ptr = attr_filter->getMatchValue();
@@ -419,13 +419,13 @@ PlatformResult MessagingDatabaseManager::getAttributeFilterQuery(AbstractFilterP
         } else if ("messaging.email" == match_value && MessageType::EMAIL == msgType) {
             sqlQuery << "= " << attr_info.sql_name;
         } else {
-            LoggerE("attribute \"type\" matchValue:%s "
-                    "does not match messaging.sms/mms/email\n"
-                    "msgType:%d does not match SMS(%d), MMS(%d) nor EMAIL(%d)!",
-                    match_value.c_str(), msgType, MessageType::SMS, MessageType::MMS,
-                    MessageType::EMAIL);
-            return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                  "The value does not match service type.");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "The value does not match service type.",
+                      ("attribute \"type\" matchValue:%s "
+                       "does not match messaging.sms/mms/email\n"
+                       "msgType:%d does not match SMS(%d), MMS(%d) nor EMAIL(%d)!",
+                       match_value.c_str(), msgType, MessageType::SMS, MessageType::MMS,
+                       MessageType::EMAIL));
         }
     }
     else if ("isRead" == attribute_name || "hasAttachment" == attribute_name) {
@@ -547,8 +547,9 @@ PlatformResult MessagingDatabaseManager::getAttributeFilterQuery(AbstractFilterP
                 break;
             }
             default:
-              return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                    "The match flag is incorrect.");
+              return LogAndCreateResult(
+                        ErrorCode::UNKNOWN_ERR, "The match flag is incorrect.",
+                        ("The match flag is incorrect: %d", match_flag));
         }
 
         if (MessageType::SMS == msgType || MessageType::MMS == msgType) {
@@ -579,9 +580,9 @@ PlatformResult MessagingDatabaseManager::getAttributeRangeFilterQuery(AbstractFi
 
     AttributeRangeFilterPtr attr_range_filter = castToAttributeRangeFilter(filter);
     if(!attr_range_filter) {
-        LoggerE("passed filter is not valid AttributeRangeFilter!");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Wrong filter type - not attribute range filter");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Wrong filter type - not attribute range filter",
+                  ("passed filter is not valid AttributeRangeFilter!"));
     }
 
     converter << attr_range_filter->getInitialValue()->toTimeT();
@@ -604,9 +605,9 @@ PlatformResult MessagingDatabaseManager::getCompositeFilterQuery(AbstractFilterP
 
     CompositeFilterPtr comp_filter = castToCompositeFilter(filter);
     if(!comp_filter) {
-        LoggerE("passed filter is not valid CompositeFilter!");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Wrong filter type - not composite filter");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Wrong filter type - not composite filter",
+                  ("passed filter is not valid CompositeFilter!"));
     }
 
     AbstractFilterPtrVector filters_arr = comp_filter->getFilters();
@@ -655,10 +656,9 @@ PlatformResult MessagingDatabaseManager::getCompositeFilterQuery(AbstractFilterP
               break;
             }
             default:
-                LoggerE("Error while querying message - unsupported filter type: %d",
-                        filter_type);
-                return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                      "Error while querying message.");
+                return LogAndCreateResult(
+                          ErrorCode::UNKNOWN_ERR, "Error while querying message.",
+                          ("Error while querying message - unsupported filter type: %d", filter_type));
         }
 
         if (i != (size - 1)) {
@@ -683,8 +683,9 @@ PlatformResult MessagingDatabaseManager::addFilters(AbstractFilterPtr filter,
         if (UNDEFINED != msg_type) {
             sql_query << attribute_map["type"].sql_name << " = " << msg_type << " AND ";
         } else {
-            LoggerE("The service type is incorrect - msg_type is UNDEFINED");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "The service type is incorrect.");
+            return LogAndCreateResult(
+                      ErrorCode::UNKNOWN_ERR, "The service type is incorrect.",
+                      ("The service type is incorrect - %d", msg_type));
         }
     }
 
@@ -722,8 +723,9 @@ PlatformResult MessagingDatabaseManager::addFilters(AbstractFilterPtr filter,
               break;
             }
             default:
-                LoggerE("The filter type is incorrect: %d", filter->getFilterType());
-                return PlatformResult(ErrorCode::UNKNOWN_ERR, "The filter type is incorrect.");
+                return LogAndCreateResult(
+                          ErrorCode::UNKNOWN_ERR, "The filter type is incorrect.",
+                          ("The filter type is incorrect: %d", filter->getFilterType()));
         }
     }
 
@@ -733,8 +735,7 @@ PlatformResult MessagingDatabaseManager::addFilters(AbstractFilterPtr filter,
             sql_query << "ORDER BY "
                     << attribute_map[sort_mode->getAttributeName()].sql_name << " ";
         } else {
-            LoggerE("The attribute does not exist.");
-            return PlatformResult(ErrorCode::UNKNOWN_ERR, "The attribute does not exist.");
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "The attribute does not exist.");
         }
 
         if (ASC == sort_mode->getOrder()) {
@@ -807,10 +808,10 @@ PlatformResult MessagingDatabaseManager::findShortMessages(
     // Getting results from database
     msg_error_t err = getTable(sqlQuery.str(), &results, &resultsCount);
     if (MSG_SUCCESS != err) {
-        LoggerE("Getting results from database failed [%d]", err);
         freeTable(&results);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Error while getting data from database.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+                  ("getTable error: %d (%s)", err, get_error_message(err)));
     }
 
     for (int i = 0; i < resultsCount; ++i) {
@@ -860,8 +861,9 @@ PlatformResult MessagingDatabaseManager::findEmails(
         if (EMAIL_ERROR_MAIL_NOT_FOUND == err) {
             resultsCount = 0;
         } else {
-          return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                "Error while getting data from database.");
+          return LogAndCreateResult(
+                    ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+                    ("email_query_mails error: %d (%s)", err, get_error_message(err)));
         }
     }
 
@@ -908,10 +910,10 @@ PlatformResult MessagingDatabaseManager::findShortMessageConversations(
     // Getting results from database
     msg_error_t err = getTable(sqlQuery.str(), &results, &resultsCount);
     if (MSG_SUCCESS != err) {
-        LoggerE("Getting results from database failed [%d]", err);
         freeTable(&results);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                              "Error while getting data from database.");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+                  ("getTable error: %d (%s)", err, get_error_message(err)));
     }
 
     for (int i = 0; i < resultsCount; ++i) {
@@ -963,8 +965,9 @@ PlatformResult MessagingDatabaseManager::findEmailConversations(
         if (EMAIL_ERROR_MAIL_NOT_FOUND == err) {
             resultsCount = 0;
         } else {
-          return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                "Error while getting data from database.");
+          return LogAndCreateResult(
+                    ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+                    ("email_query_mails error: %d (%s)", err, get_error_message(err)));
         }
     }
 
index 2d104e333e1483b4a8a6926f6a4429e0975efbaa..b8c7df4b9d43168693090311cab7f945896e2ad7 100755 (executable)
@@ -160,9 +160,8 @@ MessagingInstance::~MessagingInstance()
 }
 
 #define POST_AND_RETURN(ret, json, obj, action) \
-    LoggerE("Error occured: (%s)", ret.message().c_str()); \
     picojson::object args; \
-    ReportError(ret, &args); \
+    LogAndReportError(ret, &args); \
     obj[JSON_DATA] = picojson::value(args); \
     obj[JSON_ACTION] = picojson::value(action); \
     queue_.addAndResolve( \
@@ -336,8 +335,8 @@ void MessagingInstance::MessageServiceSync(const picojson::value& args,
     try {
         id = std::stoi(v_id.get<std::string>());
     } catch(...) {
-        LoggerE("Problem with MessageService");
-        ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+        LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+                          ("Problem with MessageService"));
         return;
     }
     long limit = 0;
@@ -357,7 +356,7 @@ void MessagingInstance::MessageServiceSync(const picojson::value& args,
     if (result) {
       ReportSuccess(picojson::value(static_cast<double>(op_id)), out);
     } else {
-      ReportError(result, &out);
+      LogAndReportError(result, &out);
     }
 }
 
@@ -382,8 +381,8 @@ void MessagingInstance::MessageServiceSyncFolder(const picojson::value& args,
     try {
         id = std::stoi(v_id.get<std::string>());
     } catch(...) {
-        LoggerE("Problem with MessageService");
-        ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+        LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+                          ("Problem with MessageService"));
         return;
     }
 
@@ -404,7 +403,7 @@ void MessagingInstance::MessageServiceSyncFolder(const picojson::value& args,
     if (result) {
         ReportSuccess(picojson::value(static_cast<double>(op_id)), out);
     } else {
-        ReportError(result, &out);
+        LogAndReportError(result, &out);
     }
 }
 
@@ -429,8 +428,8 @@ void MessagingInstance::MessageServiceStopSync(const picojson::value& args,
         try {
             id = std::stoi(v_id.get<std::string>());
         } catch(...) {
-            LoggerD("Problem with MessageService");
-            ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+            LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+                              ("Problem with MessageService"));
             return;
         }
 
@@ -444,11 +443,11 @@ void MessagingInstance::MessageServiceStopSync(const picojson::value& args,
         if (result) {
             ReportSuccess(out);
         } else {
-            ReportError(result, &out);
+            LogAndReportError(result, &out);
         }
     } else {
-        LoggerE("Unknown error");
-        ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+        LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+                          ("Unknown error"));
     }
 }
 
index 32e45d475c1b59a5f944dd6bac7878974a752628..f4bc602a3a787294b4f18d186ed2cb1bbcdd669a 100755 (executable)
@@ -120,8 +120,8 @@ static void* getMsgServicesThread(const std::shared_ptr<MsgManagerCallbackData>&
           MessageService* service = MessageServiceShortMsg::GetSmsMessageService();
 
           if (!service) {
-            LoggerE("MessageService for SMS creation failed");
-            platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
+            platform_result = LogAndCreateResult(
+                                  ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
           } else {
             *(user_data->sms_service) = std::make_pair(service->getMsgServiceId(), service);
 
@@ -146,8 +146,8 @@ static void* getMsgServicesThread(const std::shared_ptr<MsgManagerCallbackData>&
           MessageService* service = MessageServiceShortMsg::GetMmsMessageService();
 
           if (!service) {
-            LoggerE("MessageService for MMS creation failed");
-            platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
+            platform_result = LogAndCreateResult(
+                                  ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
           } else {
             *(user_data->mms_service) = std::make_pair(service->getMsgServiceId(), service);
 
@@ -168,9 +168,11 @@ static void* getMsgServicesThread(const std::shared_ptr<MsgManagerCallbackData>&
           email_account_t* email_accounts = nullptr;
           int count = 0;
 
-          if (email_get_account_list(&email_accounts, &count) != EMAIL_ERROR_NONE) {
-            LoggerE("Method failed: email_get_account_list()");
-            platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Error during getting account list");
+          int ntv_ret = email_get_account_list(&email_accounts, &count);
+          if (ntv_ret != EMAIL_ERROR_NONE) {
+            platform_result = LogAndCreateResult(
+                                  ErrorCode::UNKNOWN_ERR, "Error during getting account list",
+                                  ("email_get_account_list error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
           } else {
             std::vector<MessageService*> msgServices;
 
@@ -193,8 +195,8 @@ static void* getMsgServicesThread(const std::shared_ptr<MsgManagerCallbackData>&
                                 delete service;
                               });
                 msgServices.clear();
-                LoggerE("MessageService for email creation failed");
-                platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "MessageService for email creation failed");
+                platform_result = LogAndCreateResult(
+                                     ErrorCode::UNKNOWN_ERR, "MessageService for email creation failed");
               } else {
                 msgServices.push_back(service);
               }
@@ -226,11 +228,10 @@ static void* getMsgServicesThread(const std::shared_ptr<MsgManagerCallbackData>&
         }
         break;
       default:
-        platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Service type is undefined");
+        platform_result = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Service type is undefined");
     }
   } else {
-    LoggerE("Unsupported service type");
-    platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Unsupported service type");
+    platform_result = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Unsupported service type");
   }
 
   if (!platform_result) {
index 1ee370ab61d00743ea23ca84f0aacd3ad83a1488..ebe68bf4a5df85402e147befa590917141d2e746 100755 (executable)
@@ -200,8 +200,9 @@ PlatformResult MessagingUtil::stringToMessageType(const std::string& str, Messag
   const auto it = stringToTypeMap.find(str);
 
   if (it == stringToTypeMap.end()) {
-    LoggerE("Not supported type: %s", str.c_str());
-    return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Not supported type: " + str);
+    return LogAndCreateResult(
+              ErrorCode::TYPE_MISMATCH_ERR, "Not supported type: " + str,
+              ("Not supported type: %s", str.c_str()));
   } else {
     *out = it->second;
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -214,8 +215,9 @@ common::PlatformResult MessagingUtil::messageTypeToString(MessageType type, std:
   const auto it = typeToStringMap.find(type);
 
   if (it == typeToStringMap.end()) {
-    LoggerE("Invalid MessageType: %d", type);
-    return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid MessageType");
+    return LogAndCreateResult(
+              ErrorCode::TYPE_MISMATCH_ERR, "Invalid MessageType",
+              ("Invalid MessageType: %d", type));
   } else {
     *out = it->second;
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -297,7 +299,7 @@ PlatformResult MessagingUtil::loadFileContentToString(const std::string& file_pa
     } else {
         std::stringstream ss_error_msg;
         ss_error_msg << "Failed to open file: " << file_path;
-        return PlatformResult(ErrorCode::IO_ERR, ss_error_msg.str().c_str());
+        return LogAndCreateResult(ErrorCode::IO_ERR, ss_error_msg.str().c_str());
     }
     return PlatformResult(ErrorCode::NO_ERROR);
 }
@@ -751,9 +753,9 @@ PlatformResult MessagingUtil::jsonToMessage(const picojson::value& json,
             int mail_id = std::atoi(mid.c_str());
             email_mail_data_t* mail = NULL;
             if (EMAIL_ERROR_NONE != email_get_mail_data(mail_id, &mail)) {
-                LoggerE("Fatal error: message not found: %d!", mail_id);
-                return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
-                                      "Failed to find specified email.");
+                return LogAndCreateResult(
+                            ErrorCode::TYPE_MISMATCH_ERR, "Failed to find specified email.",
+                            ("Fatal error: message not found: %d!", mail_id));
             } else {
                 platform_result = Message::convertPlatformEmailToObject(*mail, &message);
                 email_free_mail_data(&mail,1);
@@ -774,8 +776,7 @@ PlatformResult MessagingUtil::jsonToMessage(const picojson::value& json,
       if (!v.is<std::string>()) {
         const std::string message = "Passed array holds incorrect values "
             + v.serialize() + " is not a correct string value";
-        LoggerE("Error: %s", message.c_str());
-        conv_res = PlatformResult(ErrorCode::INVALID_VALUES_ERR, message);
+        conv_res = LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, message);
       }
       if (conv_res.IsError()) {
         return;
@@ -979,8 +980,9 @@ PlatformResult MessagingUtil::jsonFilterToAbstractFilter(const picojson::object&
         return jsonFilterToCompositeFilter(filter, result);
     }
 
-    LoggerE("Unsupported filter type: %s", type.c_str());
-    return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Unsupported filter type");
+    return LogAndCreateResult(
+              ErrorCode::TYPE_MISMATCH_ERR, "Unsupported filter type",
+              ("Unsupported filter type: %s", type.c_str()));
 }
 
 PlatformResult MessagingUtil::jsonFilterToAttributeFilter(const picojson::object& filter,
@@ -1014,8 +1016,9 @@ PlatformResult MessagingUtil::jsonFilterToAttributeFilter(const picojson::object
         filterMatch = FilterMatchFlag::EXISTS;
     }
     else {
-        LoggerE("Filter name is not recognized: %s", matchFlagStr.c_str());
-        return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Filter name is not recognized");
+        return LogAndCreateResult(
+                  ErrorCode::TYPE_MISMATCH_ERR, "Filter name is not recognized",
+                  ("Filter name is not recognized: %s", matchFlagStr.c_str()));
     }
 
     auto attributePtr = new AttributeFilter(name);
@@ -1058,9 +1061,9 @@ PlatformResult MessagingUtil::jsonFilterToCompositeFilter(const picojson::object
         filterType = CompositeFilterType::INTERSECTION;
     }
     else {
-        LoggerE("Composite filter type is not recognized: %s", type.c_str());
-        return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
-                              "Composite filter type is not recognized");
+        return LogAndCreateResult(
+                  ErrorCode::TYPE_MISMATCH_ERR, "Composite filter type is not recognized",
+                  ("Composite filter type is not recognized: %s", type.c_str()));
     }
 
     auto compositeFilter = new CompositeFilter(filterType);
index 918eb661eca94b45407264577ba154aa49db20a4..bf9ca8f5fd95557fb930f84d1c408ec85ef2ffe4 100755 (executable)
@@ -135,18 +135,18 @@ PlatformResult ShortMsgManager::addDraftMessagePlatform(std::shared_ptr<Message>
     }
 
     if (NULL == platform_msg) {
-        LoggerE("Failed to prepare platform message");
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message");
+        return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message");
     }
 
     msg_struct_t send_opt = msg_create_struct(MSG_STRUCT_SENDOPT);
     msg_set_bool_value(send_opt, MSG_SEND_OPT_SETTING_BOOL, false);
     const int msg_id = msg_add_message(m_msg_handle, platform_msg, send_opt);
     if (msg_id < MSG_SUCCESS) {
-        LoggerE("Message(%p): Failed to add draft, error: %d", message.get(), msg_id);
         msg_release_struct(&send_opt);
         msg_release_struct(&platform_msg);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot add message to draft");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Cannot add message to draft",
+                  ("Message(%p): Failed to add draft, error: %d", message.get(), msg_id));
     }
 
     LoggerD("Message(%p): New message ID: %d", message.get(), msg_id);
@@ -161,7 +161,7 @@ PlatformResult ShortMsgManager::addDraftMessagePlatform(std::shared_ptr<Message>
         msg_get_int_value(msg_conv, MSG_CONV_MSG_THREAD_ID_INT, &conversationId);
         message->setConversationId(conversationId);
     } else {
-        LoggerE("Message(%p): Failed to get conv", message.get());
+        LoggerE("Message(%p): Failed to get conv: %d (%s)", message.get(), err, get_error_message(err));
     }
     Message* msgInfo = nullptr;
     ret = Message::convertPlatformShortMessageToObject(
@@ -232,8 +232,9 @@ PlatformResult ShortMsgManager::SendMessagePlatform(MessageRecipientsCallbackDat
     msg_conv = msg_create_struct(MSG_STRUCT_CONV_INFO);
     ret = msg_get_message(m_msg_handle, msg_id, platform_msg, send_opt);
     if (MSG_SUCCESS != ret) {
-      LoggerE("Failed to get platform message structure: %d", ret);
-      platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure");
+      platform_result = LogAndCreateResult(
+                            ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure",
+                            ("msg_get_message error: %d (%s)", ret, get_error_message(ret)));
     } else {
       // Send message
       message->setMessageStatus(MessageStatus::STATUS_SENDING);
@@ -243,8 +244,9 @@ PlatformResult ShortMsgManager::SendMessagePlatform(MessageRecipientsCallbackDat
       int req_id = -1;
       ret = msg_get_int_value(req, MSG_REQUEST_REQUESTID_INT, &req_id);
       if (MSG_SUCCESS != ret) {
-        LoggerE("Failed to get send request ID: %d", ret);
-        platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get send request ID");
+        platform_result = LogAndCreateResult(
+                              ErrorCode::UNKNOWN_ERR, "Failed to get send request ID",
+                              ("msg_get_int_value error: %d (%s)", ret, get_error_message(ret)));
       } else {
         if (MessageType::MMS == message->getType()) {
           LoggerD("Send MMS message");
@@ -255,19 +257,22 @@ PlatformResult ShortMsgManager::SendMessagePlatform(MessageRecipientsCallbackDat
           ret = msg_sms_send_message(m_msg_handle, req);
         }
         else {
-          LoggerE("Invalid message type: %d", message->getType());
-          platform_result = PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid message type");
+          platform_result = LogAndCreateResult(
+                                ErrorCode::TYPE_MISMATCH_ERR, "Invalid message type",
+                                ("Invalid message type: %d", message->getType()));
         }
 
         if (platform_result) {
           if (ret != MSG_SUCCESS) {
-            LoggerE("Failed to send message: %d", ret);
-            platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to send message");
+            platform_result = LogAndCreateResult(
+                                  ErrorCode::UNKNOWN_ERR, "Failed to send message",
+                                  ("Failed to send message: %d (%s)", ret, get_error_message(ret)));
           } else {
             ret = msg_get_int_value(req, MSG_REQUEST_REQUESTID_INT, &req_id);
             if (ret != MSG_SUCCESS) {
-              LoggerE("Failed to get message request ID: %d", ret);
-              platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get send request");
+              platform_result = LogAndCreateResult(
+                                    ErrorCode::UNKNOWN_ERR, "Failed to get send request",
+                                    ("Failed to get message request ID: %d (%s)", ret, get_error_message(ret)));
             }
             if (platform_result.IsSuccess()) {
               LoggerD("req_id: %d", req_id);
@@ -333,8 +338,7 @@ PlatformResult ShortMsgManager::sendMessage(MessageRecipientsCallbackData* callb
   LoggerD("Entered");
 
   if (!callback){
-    LoggerE("Callback is null");
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+    return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
   }
 
   PlatformResult platform_result(ErrorCode::NO_ERROR);
@@ -384,13 +388,14 @@ void ShortMsgManager::sendStatusCallback(msg_struct_t sent_status)
 
         if (MSG_NETWORK_SEND_FAIL == status
                 || MSG_NETWORK_SEND_TIMEOUT == status) {
-            LoggerE("req_id:%d : Failed sending Message(%p) with msg_id:%d msg status is: %s",
-                reqId,
-                callback->getMessage().get(),
-                callback->getMessage()->getId(),
-                (MSG_NETWORK_SEND_FAIL == status ? "FAIL" : "TIMEOUT"));
+            callback->SetError(LogAndCreateResult(
+                                  ErrorCode::UNKNOWN_ERR, "Send message failed",
+                                  ("req_id:%d : Failed sending Message(%p) with msg_id:%d msg status is: %s",
+                                    reqId,
+                                    callback->getMessage().get(),
+                                    callback->getMessage()->getId(),
+                                    (MSG_NETWORK_SEND_FAIL == status ? "FAIL" : "TIMEOUT"))));
 
-            callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Send message failed"));
         }
 
         if (!g_idle_add(sendMessageCompleteCB, static_cast<void*>(callback))) {
@@ -750,8 +755,9 @@ void ShortMsgManager::removeMessages(MessagesCallbackUserData* callback)
         MessageType type = callback->getMessageServiceType();
         for(auto it = messages.begin() ; it != messages.end(); ++it) {
             if((*it)->getType() != type) {
-                LoggerE("Invalid message type: %d", (*it)->getType());
-                callback->SetError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting message"));
+                callback->SetError(LogAndCreateResult(
+                                      ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting message",
+                                      ("Invalid message type: %d", (*it)->getType())));
                 break;
             }
         }
@@ -773,8 +779,9 @@ void ShortMsgManager::removeMessages(MessagesCallbackUserData* callback)
 
                int error = msg_delete_message(m_msg_handle, id);
                 if (MSG_SUCCESS != error) {
-                    LoggerE("Error while deleting message");
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting message"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::UNKNOWN_ERR, "Error while deleting message",
+                                          ("msg_delete_message error: %d (%s)", error, get_error_message(error))));
                     break;
                 }
             }
@@ -811,8 +818,9 @@ void ShortMsgManager::updateMessages(MessagesCallbackUserData* callback)
         MessageType type = callback->getMessageServiceType();
         for (auto it = messages.begin() ; it != messages.end(); ++it) {
             if ((*it)->getType() != type) {
-                LoggerE("Invalid message type");
-                callback->SetError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message"));
+                callback->SetError(LogAndCreateResult(
+                                      ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message",
+                                      ("Invalid message type %d", (*it)->getType())));
                 break;
             }
         }
@@ -828,8 +836,7 @@ void ShortMsgManager::updateMessages(MessagesCallbackUserData* callback)
                     break;
                 }
                 if (NULL == platform_msg) {
-                    LoggerE("Failed to prepare platform message");
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message"));
+                    callback->SetError(LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message"));
                     break;
                 }
                 msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
@@ -837,8 +844,9 @@ void ShortMsgManager::updateMessages(MessagesCallbackUserData* callback)
                 msg_release_struct(&platform_msg);
                 msg_release_struct(&sendOpt);
                 if (error != MSG_SUCCESS) {
-                    LoggerE("Failed to update message %d", (*it)->getId());
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while updating message"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::UNKNOWN_ERR, "Error while updating message",
+                                          ("Failed to update message %d", (*it)->getId())));
                     break;
                 }
             }
@@ -875,10 +883,11 @@ PlatformResult ShortMsgManager::getMessage(int msg_id, msg_struct_t* out_msg)
 
     int error = msg_get_message(m_msg_handle, msg_id, msg, sendOpt);
     if (MSG_SUCCESS != error) {
-        LoggerE("Couldn't retrieve message from service, msgId: %d, error:%d", msg_id, error);
         msg_release_struct(&sendOpt);
         msg_release_struct(&msg);
-        return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't retrieve message from service");
+        return LogAndCreateResult(
+                  ErrorCode::UNKNOWN_ERR, "Couldn't retrieve message from service",
+                  ("Couldn't retrieve message from service, msgId: %d, error:%d", msg_id, error));
     }
     msg_release_struct(&sendOpt);
     *out_msg = msg;
@@ -954,8 +963,9 @@ void ShortMsgManager::findMessages(FindMsgCallbackUserData* callback)
                 err = msg_get_message(m_msg_handle, messagesIds.at(i), msg, send_opt);
 
                 if (MSG_SUCCESS != err) {
-                    LoggerE("Failed to get platform message structure: %d", err);
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure",
+                                          ("Failed to get platform message structure: %d (%s)", err, get_error_message(err))));
                     break;
                 }
 
@@ -966,8 +976,8 @@ void ShortMsgManager::findMessages(FindMsgCallbackUserData* callback)
                       LoggerW("Ignore messages with not supported/unrecognized type");
                       continue;
                     }
-                    LoggerE("Cannot get platform Message structure");
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure"));
                     break;
                 }
                 if (!callback->IsError()) {
@@ -1079,16 +1089,17 @@ void ShortMsgManager::removeConversations(ConversationCallbackData* callback)
 
         error = msg_open_msg_handle(&handle);
         if (MSG_SUCCESS != error) {
-            LoggerE("Open message handle error: %d", error);
-            callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while creatng message handle"));
+            callback->SetError(LogAndCreateResult(
+                                  ErrorCode::UNKNOWN_ERR, "Error while creatng message handle",
+                                  ("Open message handle error: %d (%s)", error, get_error_message(error))));
         }
 
         if (!callback->IsError()) {
           for(auto it = conversations.begin() ; it != conversations.end(); ++it) {
               if((*it)->getType() != type) {
-                  LoggerE("Invalid message type");
-                  callback->SetError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
-                                     "Error while deleting message conversation"));
+                  callback->SetError(LogAndCreateResult(
+                                        ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting message conversation",
+                                        ("Invalid message type %d", (*it)->getType())));
                   break;
               }
           }
@@ -1102,8 +1113,9 @@ void ShortMsgManager::removeConversations(ConversationCallbackData* callback)
                 msg_id_conv_id_map = &m_mms_removed_msg_id_conv_id_map;
                 conv_id_object_map = &m_mms_removed_conv_id_object_map;
             } else {
-                LoggerE("Invalid message type:%d for ShortMsgManager!", type);
-                callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid message type for ShortMsgManager!"));
+                callback->SetError(LogAndCreateResult(
+                                      ErrorCode::UNKNOWN_ERR, "Invalid message type for ShortMsgManager!",
+                                      ("Invalid message type:%d for ShortMsgManager!", type)));
             }
         }
 
@@ -1149,9 +1161,10 @@ void ShortMsgManager::removeConversations(ConversationCallbackData* callback)
                 error = msg_delete_thread_message_list(handle, (msg_thread_id_t) conv_id,
                         FALSE);
                 if (MSG_SUCCESS != error) {
-                    LoggerE("Error while deleting message conversation");
-                    callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR,
-                                                      "Error while deleting message conversation"));
+                    callback->SetError(LogAndCreateResult(
+                                          ErrorCode::UNKNOWN_ERR, "Error while deleting message conversation",
+                                          ("msg_delete_thread_message_list error: %d (%s)",
+                                              error, get_error_message(error))));
                     break;
                 }
             }