Handle cancel event not to be printed as error 06/78106/2
authorKyungwook Tak <k.tak@samsung.com>
Mon, 4 Jul 2016 09:18:59 +0000 (18:18 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 4 Jul 2016 09:27:53 +0000 (18:27 +0900)
Change-Id: Iabc4fd9abf7ceb52ce04f00d6688599e29c92d1c
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/client/async-logic.cpp
src/framework/service/exception.cpp

index 454c184..5ed5192 100644 (file)
@@ -58,11 +58,9 @@ void AsyncLogic::scanHelper(const CommandId &id, const StrSet &s)
        if (ret != ASYNC_EVENT_START)
                ThrowExc(ret, "Error on async scan. ret: " << ret);
 
-       bool isDone = false;
-
        DEBUG("loop for waiting server event start!!");
 
-       while (!isDone) {
+       while (true) {
                auto event = this->m_handle->revent<int>();
 
                DEBUG("event received: " << event);
@@ -105,8 +103,11 @@ void AsyncLogic::scanHelper(const CommandId &id, const StrSet &s)
 
                case ASYNC_EVENT_COMPLETE: {
                        DEBUG("Async operation completed");
-                       isDone = true;
-                       break;
+                       return;
+               }
+
+               case ASYNC_EVENT_CANCEL: {
+                       ThrowExcInfo(ASYNC_EVENT_CANCEL, "Async operation cancelled!");
                }
 
                default:
index 7e5bf95..f395e10 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "common/audit/logger.h"
 #include "common/binary-queue.h"
+#include "common/async-protocol.h"
+
 #include <csr-error.h>
 
 namespace Csr {
@@ -35,7 +37,11 @@ RawBuffer exceptionGuard(const std::function<RawBuffer()> &func)
        try {
                return func();
        } catch (const Exception &e) {
-               ERROR("Exception caught. code: " << e.error() << " message: " << e.what());
+               if (e.error() == ASYNC_EVENT_CANCEL)
+                       INFO("Async operation cancel exception: " << e.what());
+               else
+                       ERROR("Exception caught. code: " << e.error() << " message: " << e.what());
+
                return BinaryQueue::Serialize(e.error()).pop();
        } catch (const std::invalid_argument &e) {
                ERROR("Invalid argument: " << e.what());