Commit 733a802d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

sqlite: Fix error codes handling

Moving to extended error codes made all logic depending on the simple
error codes to fail. So far we only use extended error codes for logging
parent d5812491
......@@ -53,9 +53,9 @@ public:
class GenericExecution : public Generic
{
public:
GenericExecution( const char* req, const char* errMsg, int errCode )
GenericExecution( const char* req, const char* errMsg, int errCode, int extendedCode )
: Generic( std::string( "Failed to run request <" ) + req + ">: " + errMsg +
"(" + std::to_string( errCode ) + ")" )
"(" + std::to_string( extendedCode ) + ")" )
, m_errorCode( errCode )
{
}
......
......@@ -161,7 +161,8 @@ public:
auto maxRetries = 10;
while ( true )
{
auto res = sqlite3_step( m_stmt.get() );
auto extRes = sqlite3_step( m_stmt.get() );
auto res = extRes & 0xFF;
if ( res == SQLITE_ROW )
return Row( m_stmt.get() );
else if ( res == SQLITE_DONE )
......@@ -175,7 +176,7 @@ public:
case SQLITE_CONSTRAINT:
throw errors::ConstraintViolation( sqlite3_sql( m_stmt.get() ), errMsg );
default:
throw errors::GenericExecution( sqlite3_sql( m_stmt.get() ), errMsg, res );
throw errors::GenericExecution( sqlite3_sql( m_stmt.get() ), errMsg, res, extRes );
}
}
}
......
Markdown is supported
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