diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-12-01 23:08:40 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-12-03 15:38:36 +0100 |
commit | c279fb171700c464c1cdac5cd2da39f142274d8d (patch) | |
tree | 1cd300b174ba13df6869b3c8bd591f07f0d66582 /platform | |
parent | 0c351eb523d80fa534bd239b6d5e677e3d5635bb (diff) | |
download | qtlocation-mapboxgl-c279fb171700c464c1cdac5cd2da39f142274d8d.tar.gz |
[core] throw values, catch references
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/sqlite3.cpp | 10 | ||||
-rw-r--r-- | platform/default/sqlite3.hpp | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/platform/default/sqlite3.cpp b/platform/default/sqlite3.cpp index 87aafa3929..742c7e3217 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 3e324f7ce1..1cad56f918 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; }; |