Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Throw better error descriptions along with the code
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Nov 15, 2023
1 parent 1a9e3d6 commit 367a04a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ BridgeResult sqliteExecute(std::string const dbName,
bool isConsuming = true;
bool isFailed = false;

int result = SQLITE_OK;

do {
const char *queryStr = remainingStatement == nullptr ? query.c_str() : remainingStatement;

Expand All @@ -274,15 +276,15 @@ BridgeResult sqliteExecute(std::string const dbName,
const char *message = sqlite3_errmsg(db);
return {
.type = SQLiteError,
.message = "[op-sqlite] SQL execution error: " + std::string(message),
.message = "[op-sqlite] SQL statement error: " + std::string(message),
};
}

bindStatement(statement, params);

isConsuming = true;

int result, i, count, column_type;
int i, count, column_type;
std::string column_name, column_declared_type;

while (isConsuming)
Expand Down Expand Up @@ -390,15 +392,15 @@ BridgeResult sqliteExecute(std::string const dbName,
}

sqlite3_finalize(statement);
} while (strcmp(remainingStatement, "") != 0 && !isFailed);
} while (remainingStatement != NULL && strcmp(remainingStatement, "") != 0 && !isFailed);


if (isFailed)
{
const char *message = sqlite3_errmsg(db);
return {
.type = SQLiteError,
.message = "[op-sqlite] SQL execution error: " + std::string(message)
.message = "[op-sqlite] SQLite code: " + std::to_string(result) + " execution error: " + std::string(message)
};
}

Expand Down Expand Up @@ -434,7 +436,7 @@ BridgeResult sqliteExecuteLiteral(std::string const dbName, std::string const &q
const char *message = sqlite3_errmsg(db);
return {
SQLiteError,
"[op-sqlite] SQL execution error: " + std::string(message),
"[op-sqlite] SQL statement error: " + std::string(message),
0};
}

Expand Down

0 comments on commit 367a04a

Please sign in to comment.