Improve error handling for CheckDatabaseExists