Skip to content

Commit

Permalink
DBSQLite3: Do not raise in destructor
Browse files Browse the repository at this point in the history
Throwing exception from destructor is not recommended and generates lots
of warnings during compilation.
Don't use macro SQLRES, and:
 - ignore return code of sqlite3_finalize (of no interest here)
 - log to stderr sqlite3_close failure
  • Loading branch information
Nestorfish authored and sfan5 committed Oct 8, 2016
1 parent 0bf0d8e commit bcbfd00
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions db-sqlite3.cpp
@@ -1,5 +1,6 @@
#include <stdexcept>
#include <unistd.h> // for usleep
#include <iostream>
#include "db-sqlite3.h"
#include "types.h"

Expand Down Expand Up @@ -31,11 +32,12 @@ DBSQLite3::DBSQLite3(const std::string &mapdir)

DBSQLite3::~DBSQLite3()
{
int result;
SQLOK(finalize(stmt_get_blocks_z));
SQLOK(finalize(stmt_get_block_pos));
sqlite3_finalize(stmt_get_blocks_z);
sqlite3_finalize(stmt_get_block_pos);

SQLOK(close(db));
if (sqlite3_close(db) != SQLITE_OK) {
std::cerr << "Error closing SQLite database." << std::endl;
};
}

std::vector<BlockPos> DBSQLite3::getBlockPos()
Expand Down

0 comments on commit bcbfd00

Please sign in to comment.