diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-08-21 13:09:26 -0700 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-08-28 07:14:54 -0700 |
commit | fcab3a81cd368c4af2c2ba95f466b3d4a11e2187 (patch) | |
tree | 20bd30c2408c58422edc297e0ebba0b0ec65f145 /platform/default | |
parent | 065f5ca87e96f2280959b9fd3ad3d6e63a99bae6 (diff) | |
download | qtlocation-mapboxgl-fcab3a81cd368c4af2c2ba95f466b3d4a11e2187.tar.gz |
Add unit tests and fixtures for OfflineDatabase::mergeDatabase
Diffstat (limited to 'platform/default')
-rw-r--r-- | platform/default/mbgl/storage/offline_database.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp index 30b76d1666..8256912d39 100644 --- a/platform/default/mbgl/storage/offline_database.cpp +++ b/platform/default/mbgl/storage/offline_database.cpp @@ -648,7 +648,7 @@ OfflineDatabase::mergeDatabase(const std::string& sideDatabasePath) { query.bind(1, sideDatabasePath); query.run(); } catch (const mapbox::sqlite::Exception& ex) { - handleError(ex, "merge databse attach"); + Log::Error(Event::Database, static_cast<int>(ex.code), "Can't attach database (%s) for merge: %s", sideDatabasePath.c_str(), ex.what()); return unexpected<std::exception_ptr>(std::current_exception()); } try { @@ -656,8 +656,7 @@ OfflineDatabase::mergeDatabase(const std::string& sideDatabasePath) { //database and attaches it. Check for matching schema version. auto sideUserVersion = static_cast<int>(getPragma<int64_t>("PRAGMA side.user_version")); if (sideUserVersion != 6) { - Log::Warning(Event::Database, "Merge database does not match user_version of main database"); - throw std::runtime_error("merge database does not match schema or has incorrect user_version"); + throw std::runtime_error("Merge database does not match schema or has incorrect user_version"); } mapbox::sqlite::Transaction transaction(*db); @@ -682,9 +681,10 @@ OfflineDatabase::mergeDatabase(const std::string& sideDatabasePath) { db->exec("DETACH DATABASE side"); // Explicit move to avoid triggering the copy constructor. return { std::move(result) }; - } catch (const mapbox::sqlite::Exception& ex) { + } catch (const std::runtime_error& ex) { db->exec("DETACH DATABASE side"); - handleError(ex, "merge databse post merge sql"); + Log::Error(Event::Database, "%s", ex.what()); + return unexpected<std::exception_ptr>(std::current_exception()); } return {}; |