From 35f7b1dc512c5c893318aac6f06da57e2667da47 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 2 Jan 2021 19:06:02 -0330 Subject: [PATCH] Don't throw exceptions with 'new'. --- .../sqlite/AbstractKeyValueRepositorySqlite.cxx | 2 +- .../sqlite/CompositeKeyValueRepositorySqlite.cxx | 8 +++++--- src/common/repository/sqlite/SqliteDatabase.hxx | 2 +- src/common/repository/sqlite/StellaDb.cxx | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx index 70603e324..01c39b366 100644 --- a/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx @@ -46,7 +46,7 @@ bool AbstractKeyValueRepositorySqlite::has(const string& key) try { SqliteStatement& stmt{stmtCount(key)}; - if (!stmt.step()) throw new SqliteError("count failed"); + if (!stmt.step()) throw SqliteError("count failed"); const bool result = stmt.columnInt(0) != 0; stmt.reset(); diff --git a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx index 933e5e893..2f0da7066 100644 --- a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx @@ -28,8 +28,10 @@ CompositeKeyValueRepositorySqlite::CompositeKeyValueRepositorySqlite( const string& colKey2, const string& colValue ) - : myDb{db}, myTableName{tableName}, myColKey1(colKey1), myColKey2(colKey2), myColValue(colValue) -{} + : myDb{db}, myTableName{tableName}, + myColKey1{colKey1}, myColKey2{colKey2}, myColValue{colValue} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - shared_ptr CompositeKeyValueRepositorySqlite::get(const string& key) @@ -46,7 +48,7 @@ bool CompositeKeyValueRepositorySqlite::has(const string& key) .bind(1, key.c_str()); if (!myStmtCountSet->step()) - throw new SqliteError("count failed"); + throw SqliteError("count failed"); Int32 rowCount = myStmtCountSet->columnInt(0); diff --git a/src/common/repository/sqlite/SqliteDatabase.hxx b/src/common/repository/sqlite/SqliteDatabase.hxx index c2e5e5b7a..c0c3ec034 100644 --- a/src/common/repository/sqlite/SqliteDatabase.hxx +++ b/src/common/repository/sqlite/SqliteDatabase.hxx @@ -73,7 +73,7 @@ void SqliteDatabase::exec(const string& sql, T arg1, Ts... args) char buffer[512]; if (snprintf(buffer, 512, sql.c_str(), arg1, args...) >= 512) - throw new runtime_error("SQL statement too long"); + throw runtime_error("SQL statement too long"); exec(buffer); } diff --git a/src/common/repository/sqlite/StellaDb.cxx b/src/common/repository/sqlite/StellaDb.cxx index ce65f0c64..27a943ddb 100644 --- a/src/common/repository/sqlite/StellaDb.cxx +++ b/src/common/repository/sqlite/StellaDb.cxx @@ -197,7 +197,7 @@ void StellaDb::migrate() stringstream ss; ss << "invalid database version " << version; - throw new SqliteError(ss.str()); + throw SqliteError(ss.str()); } } }