diff --git a/platform/default/include/mbgl/storage/offline_database.hpp b/platform/default/include/mbgl/storage/offline_database.hpp index e19dcfade9a..303ece3654d 100644 --- a/platform/default/include/mbgl/storage/offline_database.hpp +++ b/platform/default/include/mbgl/storage/offline_database.hpp @@ -98,7 +98,8 @@ class OfflineDatabase : private util::noncopyable { void initialize(); void handleError(const mapbox::sqlite::Exception&, const char* action); void handleError(const util::IOException&, const char* action); - + void handleError(const std::runtime_error &ex, const char* action); + void removeExisting(); void removeOldCacheTable(); void createSchema(); diff --git a/platform/default/src/mbgl/storage/offline_database.cpp b/platform/default/src/mbgl/storage/offline_database.cpp index 83eea7bcc47..db56e692a7d 100644 --- a/platform/default/src/mbgl/storage/offline_database.cpp +++ b/platform/default/src/mbgl/storage/offline_database.cpp @@ -124,6 +124,11 @@ void OfflineDatabase::handleError(const util::IOException& ex, const char* actio Log::Error(Event::Database, ex.code, "Can't %s: %s", action, ex.what()); } +void OfflineDatabase::handleError(const std::runtime_error &ex, const char* action) { + // What else needs to happen here?? + Log::Error(Event::Database, -1, "Can't %s: %s", action, ex.what()); +} + void OfflineDatabase::removeExisting() { Log::Warning(Event::Database, "Removing existing incompatible offline database"); @@ -1059,6 +1064,11 @@ expected OfflineDatabase::getRegion } catch (const mapbox::sqlite::Exception& ex) { handleError(ex, "load region"); return unexpected(std::current_exception()); +} catch (const std::runtime_error& ex) { + // Catch errors from malformed offline region definitions + // and skip them (as above). + handleError(ex, "load region"); + return unexpected(std::current_exception()); } expected OfflineDatabase::getRegionCompletedStatus(int64_t regionID) try {