summaryrefslogtreecommitdiffstats
path: root/common/messagequeue.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-05-01 23:50:48 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-05-01 23:50:48 +0200
commitad4d727f198a3088f1c967f6373306d1cb100d72 (patch)
tree4553152a4512ced9660be6f9f1c7df5c22c6d6b7 /common/messagequeue.cpp
parent4bbb92fd179fc00258264bd488270179ff246510 (diff)
downloadsink-ad4d727f198a3088f1c967f6373306d1cb100d72.tar.gz
sink-ad4d727f198a3088f1c967f6373306d1cb100d72.zip
Error handling
Diffstat (limited to 'common/messagequeue.cpp')
-rw-r--r--common/messagequeue.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/common/messagequeue.cpp b/common/messagequeue.cpp
index add4759..ccb5362 100644
--- a/common/messagequeue.cpp
+++ b/common/messagequeue.cpp
@@ -23,15 +23,18 @@ void MessageQueue::dequeue(const std::function<void(void *ptr, int size, std::fu
23 const std::function<void(const Error &error)> &errorHandler) 23 const std::function<void(const Error &error)> &errorHandler)
24{ 24{
25 bool readValue = false; 25 bool readValue = false;
26 mStorage.scan("", [this, resultHandler, &readValue](void *keyPtr, int keySize, void *valuePtr, int valueSize) -> bool { 26 mStorage.scan("", [this, resultHandler, errorHandler, &readValue](void *keyPtr, int keySize, void *valuePtr, int valueSize) -> bool {
27 const auto key = QByteArray::fromRawData(static_cast<char*>(keyPtr), keySize); 27 const auto key = QByteArray::fromRawData(static_cast<char*>(keyPtr), keySize);
28 if (Akonadi2::Storage::isInternalKey(key)) { 28 if (Akonadi2::Storage::isInternalKey(key)) {
29 return true; 29 return true;
30 } 30 }
31 readValue = true; 31 readValue = true;
32 resultHandler(valuePtr, valueSize, [this, key](bool success) { 32 resultHandler(valuePtr, valueSize, [this, key, errorHandler](bool success) {
33 if (success) { 33 if (success) {
34 mStorage.remove(key.data(), key.size()); 34 mStorage.remove(key.data(), key.size(), [errorHandler](const Akonadi2::Storage::Error &error) {
35 qDebug() << "Error while removing value" << error.message;
36 errorHandler(Error(error.store, error.code, "Error while removing value: " + error.message));
37 });
35 if (isEmpty()) { 38 if (isEmpty()) {
36 emit this->drained(); 39 emit this->drained();
37 } 40 }
@@ -61,6 +64,9 @@ bool MessageQueue::isEmpty()
61 return false; 64 return false;
62 } 65 }
63 return true; 66 return true;
67 },
68 [](const Akonadi2::Storage::Error &error) {
69 qDebug() << "Error while checking if empty" << error.message;
64 }); 70 });
65 return count == 0; 71 return count == 0;
66} 72}