diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-16 19:52:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-16 19:52:23 +0200 |
commit | 8fe4eace598997c3ff4c74aa04f723e8ea444239 (patch) | |
tree | bf4a15761671006fe48158ae193abb79aa92ed1f /common/storage_lmdb.cpp | |
parent | 9448988676c524e4080e18e861dbd7e1def84e44 (diff) | |
download | sink-8fe4eace598997c3ff4c74aa04f723e8ea444239.tar.gz sink-8fe4eace598997c3ff4c74aa04f723e8ea444239.zip |
Better error messages
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r-- | common/storage_lmdb.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index f7999d1..9fb2feb 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp | |||
@@ -406,7 +406,7 @@ int DataStore::NamedDatabase::scan(const QByteArray &k, const std::function<bool | |||
406 | mdb_cursor_close(cursor); | 406 | mdb_cursor_close(cursor); |
407 | 407 | ||
408 | if (rc) { | 408 | if (rc) { |
409 | Error error(d->name.toLatin1() + d->db, getErrorCode(rc), QByteArray("Key: ") + k + " : " + QByteArray(mdb_strerror(rc))); | 409 | Error error(d->name.toLatin1() + d->db, getErrorCode(rc), QByteArray("Error during scan. Key: ") + k + " : " + QByteArray(mdb_strerror(rc))); |
410 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); | 410 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); |
411 | } | 411 | } |
412 | 412 | ||
@@ -420,6 +420,11 @@ void DataStore::NamedDatabase::findLatest(const QByteArray &k, const std::functi | |||
420 | // Not an error. We rely on this to read nothing from non-existing databases. | 420 | // Not an error. We rely on this to read nothing from non-existing databases. |
421 | return; | 421 | return; |
422 | } | 422 | } |
423 | if (k.isEmpty()) { | ||
424 | Error error(d->name.toLatin1() + d->db, GenericError, QByteArray("Can't use findLatest with empty key.")); | ||
425 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); | ||
426 | return; | ||
427 | } | ||
423 | 428 | ||
424 | int rc; | 429 | int rc; |
425 | MDB_val key; | 430 | MDB_val key; |
@@ -471,10 +476,10 @@ void DataStore::NamedDatabase::findLatest(const QByteArray &k, const std::functi | |||
471 | mdb_cursor_close(cursor); | 476 | mdb_cursor_close(cursor); |
472 | 477 | ||
473 | if (rc) { | 478 | if (rc) { |
474 | Error error(d->name.toLatin1(), getErrorCode(rc), QByteArray("Key: ") + k + " : " + QByteArray(mdb_strerror(rc))); | 479 | Error error(d->name.toLatin1(), getErrorCode(rc), QByteArray("Error during find latest. Key: ") + k + " : " + QByteArray(mdb_strerror(rc))); |
475 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); | 480 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); |
476 | } else if (!foundValue) { | 481 | } else if (!foundValue) { |
477 | Error error(d->name.toLatin1(), 1, QByteArray("Key: ") + k + " : No value found"); | 482 | Error error(d->name.toLatin1(), 1, QByteArray("Error during find latest. Key: ") + k + " : No value found"); |
478 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); | 483 | errorHandler ? errorHandler(error) : d->defaultErrorHandler(error); |
479 | } | 484 | } |
480 | 485 | ||