Skip to content

Commit aa23baa

Browse files
committed
Make dtors not throw exceptions.
1 parent 9bb847a commit aa23baa

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

headeronly_src/sqlite3pp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ namespace sqlite3pp
163163

164164
protected:
165165
explicit statement(database& db, char const* stmt = nullptr);
166-
~statement() noexcept(false);
166+
~statement();
167167

168168
int prepare_impl(char const* stmt);
169169
int finish_impl(sqlite3_stmt* stmt);
@@ -311,7 +311,7 @@ namespace sqlite3pp
311311
{
312312
public:
313313
explicit transaction(database& db, bool fcommit = false, bool freserve = false);
314-
~transaction() noexcept(false);
314+
~transaction();
315315

316316
int commit();
317317
int rollback();

headeronly_src/sqlite3pp.ipp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ namespace sqlite3pp
232232
}
233233
}
234234

235-
inline statement::~statement() noexcept(false)
235+
inline statement::~statement()
236236
{
237-
auto rc = finish();
238-
if (rc != SQLITE_OK)
239-
throw database_error(db_);
237+
// finish() can return error. If you want to check the error, call
238+
// finish() explicitly before this object is destructed.
239+
finish();
240240
}
241241

242242
inline int statement::prepare(char const* stmt)
@@ -550,12 +550,13 @@ namespace sqlite3pp
550550
throw database_error(*db_);
551551
}
552552

553-
inline transaction::~transaction() noexcept(false)
553+
inline transaction::~transaction()
554554
{
555555
if (db_) {
556-
auto rc = db_->execute(fcommit_ ? "COMMIT" : "ROLLBACK");
557-
if (rc != SQLITE_OK)
558-
throw database_error(*db_);
556+
// execute() can return error. If you want to check the error,
557+
// call commit() or rollback() explicitly before this object is
558+
// destructed.
559+
db_->execute(fcommit_ ? "COMMIT" : "ROLLBACK");
559560
}
560561
}
561562

0 commit comments

Comments
 (0)