提交 9a594a62 编辑于 作者: Wongoo Lee's avatar Wongoo Lee
浏览文件

Make dtors not throw exceptions. (src dir).

无相关合并请求
显示 11 个添加10 个删除
+11 -10
......@@ -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)
......@@ -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");
}
}
......
......@@ -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);
......@@ -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();
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册