diff --git a/platform/default/sqlite3.cpp b/platform/default/sqlite3.cpp index 87aafa392..742c7e321 100644 --- a/platform/default/sqlite3.cpp +++ b/platform/default/sqlite3.cpp @@ -19,7 +19,7 @@ const static bool sqliteVersionCheck = []() { return true; }(); -#pragma GCC diagnostic pop +#pragma GCC diagnostic pop namespace mapbox { namespace sqlite { @@ -27,9 +27,9 @@ namespace sqlite { Database::Database(const std::string &filename, int flags) { const int err = sqlite3_open_v2(filename.c_str(), &db, flags, nullptr); if (err != SQLITE_OK) { - Exception ex { err, sqlite3_errmsg(db) }; + const auto message = sqlite3_errmsg(db); db = nullptr; - throw ex; + throw Exception { err, message }; } } @@ -59,9 +59,9 @@ void Database::exec(const std::string &sql) { char *msg = nullptr; const int err = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, &msg); if (msg) { - Exception ex { err, msg }; + const std::string message = msg; sqlite3_free(msg); - throw ex; + throw Exception { err, message }; } else if (err != SQLITE_OK) { throw Exception { err, sqlite3_errmsg(db) }; } diff --git a/platform/default/sqlite3.hpp b/platform/default/sqlite3.hpp index 3e324f7ce..1cad56f91 100644 --- a/platform/default/sqlite3.hpp +++ b/platform/default/sqlite3.hpp @@ -21,6 +21,7 @@ enum OpenFlag : int { struct Exception : std::runtime_error { inline Exception(int err, const char *msg) : std::runtime_error(msg), code(err) {} + inline Exception(int err, const std::string& msg) : std::runtime_error(msg), code(err) {} const int code = 0; }; diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index 18bf05911..c7278a103 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -99,7 +99,7 @@ protected: } if (i * itemSize >= pos) { - throw new std::runtime_error("Can't get element after array bounds"); + throw std::runtime_error("Can't get element after array bounds"); } else { return reinterpret_cast(array) + (i * itemSize); } diff --git a/src/mbgl/util/thread_context.cpp b/src/mbgl/util/thread_context.cpp index fba520739..b611b3d02 100644 --- a/src/mbgl/util/thread_context.cpp +++ b/src/mbgl/util/thread_context.cpp @@ -56,7 +56,7 @@ void ThreadContext::setFileSource(FileSource* fileSource) { if (current.get() != nullptr) { current.get()->fileSource = fileSource; } else { - throw new std::runtime_error("Current thread has no current ThreadContext."); + throw std::runtime_error("Current thread has no current ThreadContext."); } } @@ -72,7 +72,7 @@ void ThreadContext::setGLObjectStore(GLObjectStore* glObjectStore) { if (current.get() != nullptr) { current.get()->glObjectStore = glObjectStore; } else { - throw new std::runtime_error("Current thread has no current ThreadContext."); + throw std::runtime_error("Current thread has no current ThreadContext."); } } diff --git a/src/mbgl/util/thread_local.hpp b/src/mbgl/util/thread_local.hpp index c805735cc..540503735 100644 --- a/src/mbgl/util/thread_local.hpp +++ b/src/mbgl/util/thread_local.hpp @@ -24,13 +24,13 @@ public: }); if (ret) { - throw new std::runtime_error("Failed to init local storage key."); + throw std::runtime_error("Failed to init local storage key."); } } inline ~ThreadLocal() { if (pthread_key_delete(key)) { - throw new std::runtime_error("Failed to delete local storage key."); + throw std::runtime_error("Failed to delete local storage key."); } } @@ -45,7 +45,7 @@ public: inline void set(T* ptr) { if (pthread_setspecific(key, ptr)) { - throw new std::runtime_error("Failed to set local storage."); + throw std::runtime_error("Failed to set local storage."); } }