@@ -216,7 +216,7 @@ void Database::loadExtension(const char* apExtensionName, const char *apEntryPoi
216216 (void )apExtensionName;
217217 (void )apEntryPointName;
218218
219- throw std::runtime_error (" sqlite extensions are disabled" );
219+ throw SQLite::Exception (" sqlite extensions are disabled" );
220220#else
221221#ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION // Since SQLite 3.13 (2016-05-18):
222222 // Security warning:
@@ -248,8 +248,7 @@ void Database::key(const std::string& aKey) const
248248#else // SQLITE_HAS_CODEC
249249 if (passLen > 0 )
250250 {
251- const SQLite::Exception exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
252- throw exception;
251+ throw SQLite::Exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
253252 }
254253#endif // SQLITE_HAS_CODEC
255254}
@@ -271,33 +270,32 @@ void Database::rekey(const std::string& aNewKey) const
271270 }
272271#else // SQLITE_HAS_CODEC
273272 static_cast <void >(aNewKey); // silence unused parameter warning
274- const SQLite::Exception exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
275- throw exception;
273+ throw SQLite::Exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
276274#endif // SQLITE_HAS_CODEC
277275}
278276
279277// Test if a file contains an unencrypted database.
280278bool Database::isUnencrypted (const std::string& aFilename)
281279{
282- if (aFilename.length () > 0 )
280+ if (aFilename.empty () )
283281 {
284- std::ifstream fileBuffer (aFilename. c_str (), std::ios::in | std::ios::binary );
285- char header[ 16 ];
286- if (fileBuffer. is_open ())
287- {
288- fileBuffer. seekg ( 0 , std::ios::beg) ;
289- fileBuffer.getline (header, 16 );
290- fileBuffer. close ();
291- }
292- else
293- {
294- const SQLite::Exception exception ( " Error opening file: " + aFilename);
295- throw exception;
296- }
297- return strncmp (header, " SQLite format 3 \000 " , 16 ) == 0 ;
282+ throw SQLite::Exception ( " Could not open database, the aFilename parameter was empty. " );
283+ }
284+
285+ std::ifstream fileBuffer (aFilename. c_str (), std::ios::in | std::ios::binary);
286+ char header[ 16 ] ;
287+ if ( fileBuffer.is_open ())
288+ {
289+ fileBuffer. seekg ( 0 , std::ios::beg);
290+ fileBuffer. getline (header, 16 );
291+ fileBuffer. close ();
292+ }
293+ else
294+ {
295+ throw SQLite::Exception ( " Error opening file: " + aFilename) ;
298296 }
299- const SQLite::Exception exception ( " Could not open database, the aFilename parameter was empty. " );
300- throw exception ;
297+
298+ return strncmp (header, " SQLite format 3 \000 " , 16 ) == 0 ;
301299}
302300
303301// This is a reference implementation of live backup taken from the official sit:
0 commit comments