Skip to content
Snippets Groups Projects
Commit cbc98e05 authored by Eric Cano's avatar Eric Cano
Browse files

Added exception lauching for sqlite call that returned NULL in some cases (DB...

Added exception lauching for sqlite call that returned NULL in some cases (DB might have been corrupted).
parent d8a268a4
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
#include "SqliteRset.hpp"
#include "SqliteStmt.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/Errnum.hpp"
#include <cstring>
#include <sstream>
......@@ -218,7 +219,10 @@ optional<std::string> SqliteRset::columnOptionalString(const std::string &colNam
if(SQLITE_NULL == idxAndType.colType) {
return nullopt;
} else {
return optional<std::string>((const char *) sqlite3_column_text(m_stmt.get(), idxAndType.colIdx));
const unsigned char * column_text=sqlite3_column_text(m_stmt.get(), idxAndType.colIdx);
cta::exception::Errnum::throwOnNull(column_text,
std::string("In SqliteRset::columnOptionalString(): got NULL column text for ") + colName);
return optional<std::string>((const char *) column_text);
}
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment