From d82e4542803159badd94982198f397b28ae417e4 Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Mon, 4 Jul 2016 18:18:59 +0900 Subject: Handle cancel event not to be printed as error Change-Id: Iabc4fd9abf7ceb52ce04f00d6688599e29c92d1c Signed-off-by: Kyungwook Tak --- src/framework/client/async-logic.cpp | 11 ++++++----- src/framework/service/exception.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/framework/client/async-logic.cpp b/src/framework/client/async-logic.cpp index 454c184..5ed5192 100644 --- a/src/framework/client/async-logic.cpp +++ b/src/framework/client/async-logic.cpp @@ -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(); 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: diff --git a/src/framework/service/exception.cpp b/src/framework/service/exception.cpp index 7e5bf95..f395e10 100644 --- a/src/framework/service/exception.cpp +++ b/src/framework/service/exception.cpp @@ -26,6 +26,8 @@ #include "common/audit/logger.h" #include "common/binary-queue.h" +#include "common/async-protocol.h" + #include namespace Csr { @@ -35,7 +37,11 @@ RawBuffer exceptionGuard(const std::function &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()); -- cgit v1.2.3