Browse Source

pEpSQLite: superflous constructs

pull/15/head
heck 3 years ago
parent
commit
687d43d02c
  1. 44
      src/pEpSQLite.cc

44
src/pEpSQLite.cc

@ -47,11 +47,7 @@ namespace pEp {
bool pEpSQLite::is_open() const bool pEpSQLite::is_open() const
{ {
if (db == nullptr) { return db;
return false;
} else {
return true;
}
} }
@ -85,28 +81,28 @@ namespace pEp {
if (!is_open()) { if (!is_open()) {
DBNotOpenException e{ "pEpSQLite: execute() failed - db is not open:" }; DBNotOpenException e{ "pEpSQLite: execute() failed - db is not open:" };
throw(e); throw(e);
} else { }
pEpLogClass("called");
this->resultset.clear(); pEpLogClass("called");
char *zErrMsg = nullptr; this->resultset.clear();
int rc = ::sqlite3_exec( char *zErrMsg = nullptr;
db, int rc = ::sqlite3_exec(
stmt.c_str(), db,
(int (*)(void *, int, char **, char **)) & callback, stmt.c_str(),
this, (int(*)(void *, int, char **, char **)) & callback,
&zErrMsg); this,
if (rc != SQLITE_OK) { &zErrMsg);
if (rc == SQLITE_CONSTRAINT) { if (rc != SQLITE_OK) {
ConstraintException e{ "pEpSQLite: execute() failed with sqlite error: " + if (rc == SQLITE_CONSTRAINT) {
std::to_string(rc) + " - " + string(zErrMsg) }; ConstraintException e{ "pEpSQLite: execute() failed with sqlite error: " +
::sqlite3_free(zErrMsg); std::to_string(rc) + " - " + string(zErrMsg) };
throw(e);
}
runtime_error e{ "pEpSQLite: execute() failed with sqlite error: " +
std::to_string(rc) + " - " + string(zErrMsg) };
::sqlite3_free(zErrMsg); ::sqlite3_free(zErrMsg);
throw(e); throw(e);
} }
runtime_error e{ "pEpSQLite: execute() failed with sqlite error: " + std::to_string(rc) +
" - " + string(zErrMsg) };
::sqlite3_free(zErrMsg);
throw(e);
} }
return resultset; return resultset;
} }

Loading…
Cancel
Save