handle unknown knowledge base errors

This commit is contained in:
Chris Cromer 2022-11-01 01:17:45 -03:00
parent ffa239c418
commit 2dc643ed39
Signed by: cromer
GPG Key ID: FA91071797BEEEC2
2 changed files with 14 additions and 6 deletions

View File

@ -51,12 +51,15 @@ void obelisk::KnowledgeBase::createTable(std::function<const char*()> function)
if (result != SQLITE_OK) if (result != SQLITE_OK)
{ {
logSqliteError(result); logSqliteError(result);
throw obelisk::KnowledgeBaseException("something happened"); if (tmp)
} {
if (tmp) std::string errmsg(tmp);
{ throw obelisk::KnowledgeBaseException(errmsg);
std::string errmsg(tmp); }
throw obelisk::KnowledgeBaseException(errmsg); else
{
throw obelisk::KnowledgeBaseException();
}
} }
} }

View File

@ -43,6 +43,11 @@ namespace obelisk
const std::string errorMessage_; const std::string errorMessage_;
public: public:
KnowledgeBaseException() :
errorMessage_("an unknown error occured")
{
}
KnowledgeBaseException(const std::string& errorMessage) : KnowledgeBaseException(const std::string& errorMessage) :
errorMessage_(errorMessage) errorMessage_(errorMessage)
{ {