summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-03-18 16:08:00 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-03-18 17:09:43 -0700
commit90d271709f5b0e8698f746c1b2ec7972007b1a11 (patch)
treea22c3df7880ec0a526b306e7d5ceb824a7565926
parent7155c9bb81be17d86a4aa8ce2cee278d7abf32a4 (diff)
downloadqtlocation-mapboxgl-90d271709f5b0e8698f746c1b2ec7972007b1a11.tar.gz
[core] Add additional logging for exceptions during database connection / creation
Refs #4382
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index e1cd693662..43f7abaf9d 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -58,23 +58,36 @@ void OfflineDatabase::ensureSchema() {
removeExisting();
connect(ReadWrite | Create);
} catch (mapbox::sqlite::Exception& ex) {
- if (ex.code == SQLITE_CANTOPEN) {
- connect(ReadWrite | Create);
- } else if (ex.code == SQLITE_NOTADB) {
- removeExisting();
+ if (ex.code != SQLITE_CANTOPEN && ex.code != SQLITE_NOTADB) {
+ Log::Error(Event::Database, "Unexpected error connecting to database: %s", ex.what());
+ throw;
+ }
+
+ try {
+ if (ex.code == SQLITE_NOTADB) {
+ removeExisting();
+ }
connect(ReadWrite | Create);
+ } catch (...) {
+ Log::Error(Event::Database, "Unexpected error creating database: %s", util::toString(std::current_exception()).c_str());
+ throw;
}
}
}
- #include "offline_schema.cpp.include"
+ try {
+ #include "offline_schema.cpp.include"
- connect(ReadWrite | Create);
+ connect(ReadWrite | Create);
- // If you change the schema you must write a migration from the previous version.
- db->exec("PRAGMA auto_vacuum = INCREMENTAL");
- db->exec(schema);
- db->exec("PRAGMA user_version = 3");
+ // If you change the schema you must write a migration from the previous version.
+ db->exec("PRAGMA auto_vacuum = INCREMENTAL");
+ db->exec(schema);
+ db->exec("PRAGMA user_version = 3");
+ } catch (...) {
+ Log::Error(Event::Database, "Unexpected error creating database schema: %s", util::toString(std::current_exception()).c_str());
+ throw;
+ }
}
int OfflineDatabase::userVersion() {