Skip to content

Commit

Permalink
Make dtors not throw exceptions. (src dir).
Browse files Browse the repository at this point in the history
  • Loading branch information
iwongu committed May 3, 2016
1 parent aa23baa commit 9a594a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/sqlite3pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ namespace sqlite3pp
}
}

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

int statement::prepare(char const* stmt)
Expand Down Expand Up @@ -551,12 +551,13 @@ namespace sqlite3pp
throw database_error(*db_);
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/sqlite3pp.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ namespace sqlite3pp

protected:
explicit statement(database& db, char const* stmt = nullptr);
~statement() noexcept(false);
~statement();

int prepare_impl(char const* stmt);
int finish_impl(sqlite3_stmt* stmt);
Expand Down Expand Up @@ -312,7 +312,7 @@ namespace sqlite3pp
{
public:
explicit transaction(database& db, bool fcommit = false, bool freserve = false);
~transaction() noexcept(false);
~transaction();

int commit();
int rollback();
Expand Down

0 comments on commit 9a594a6

Please sign in to comment.