Skip to content

Commit 9a594a6

Browse files
committed
Make dtors not throw exceptions. (src dir).
1 parent aa23baa commit 9a594a6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/sqlite3pp.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ namespace sqlite3pp
234234
}
235235
}
236236

237-
statement::~statement() noexcept(false)
237+
statement::~statement()
238238
{
239-
auto rc = finish();
240-
if (rc != SQLITE_OK)
241-
throw database_error(db_);
239+
// finish() can return error. If you want to check the error, call
240+
// finish() explicitly before this object is destructed.
241+
finish();
242242
}
243243

244244
int statement::prepare(char const* stmt)
@@ -551,12 +551,13 @@ namespace sqlite3pp
551551
throw database_error(*db_);
552552
}
553553

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

src/sqlite3pp.h

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

165165
protected:
166166
explicit statement(database& db, char const* stmt = nullptr);
167-
~statement() noexcept(false);
167+
~statement();
168168

169169
int prepare_impl(char const* stmt);
170170
int finish_impl(sqlite3_stmt* stmt);
@@ -312,7 +312,7 @@ namespace sqlite3pp
312312
{
313313
public:
314314
explicit transaction(database& db, bool fcommit = false, bool freserve = false);
315-
~transaction() noexcept(false);
315+
~transaction();
316316

317317
int commit();
318318
int rollback();

0 commit comments

Comments
 (0)