Commit fea90e69 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 c23b1635
......@@ -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());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment