Commit 4d873113 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

sqlite: Provide extended error code for Generic errors as well

This might help us track why the database occasionally appears
locked on some android devices
parent 733a802d
......@@ -39,9 +39,9 @@ namespace errors
class Generic : public std::runtime_error
{
public:
Generic( const char* req, const char* msg )
Generic( const char* req, const char* msg, int extendedCode )
: std::runtime_error( std::string( "Failed to compile/prepare request <" ) + req
+ ">: " + msg )
+ ">: " + msg + "(" + std::to_string( extendedCode ) + ")" )
{
}
Generic( const std::string& msg )
......
......@@ -136,7 +136,7 @@ public:
int res = sqlite3_prepare_v2( dbConnection, req.c_str(), -1, &stmt, NULL );
if ( res != SQLITE_OK )
{
throw errors::Generic( req.c_str(), sqlite3_errmsg( dbConnection ) );
throw errors::Generic( req.c_str(), sqlite3_errmsg( dbConnection ), res );
}
m_stmt.reset( stmt );
connMap.emplace( req, CachedStmtPtr( stmt, &sqlite3_finalize ) );
......@@ -193,7 +193,7 @@ private:
{
auto res = Traits<T>::Bind( m_stmt.get(), m_bindIdx, std::forward<T>( value ) );
if ( res != SQLITE_OK )
throw errors::Generic( sqlite3_sql( m_stmt.get() ), "Failed to bind parameter" );
throw errors::Generic( sqlite3_sql( m_stmt.get() ), "Failed to bind parameter", res );
m_bindIdx++;
return true;
}
......
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