1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 02:54:33 +02:00

* Catch CLuceneError exceptions.

This commit is contained in:
Christian Muehlhaeuser
2011-02-14 17:25:45 +01:00
parent 0141f2b573
commit caf8d04ca7

View File

@@ -45,7 +45,16 @@ void
FuzzyIndex::beginIndexing()
{
m_mutex.lock();
try
{
IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, true );
}
catch( CLuceneError& error )
{
qDebug() << "Caught CLucene error:" << error.what();
Q_ASSERT( false );
}
}
@@ -60,6 +69,8 @@ FuzzyIndex::endIndexing()
void
FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QString >& fields )
{
try
{
delete m_luceneSearcher;
delete m_luceneReader;
m_luceneSearcher = 0;
@@ -93,6 +104,12 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin
}
luceneWriter.close();
}
catch( CLuceneError& error )
{
qDebug() << "Caught CLucene error:" << error.what();
Q_ASSERT( false );
}
}
@@ -109,6 +126,8 @@ FuzzyIndex::search( const QString& table, const QString& name )
QMutexLocker lock( &m_mutex );
QMap< int, float > resultsmap;
try
{
if ( !m_luceneReader )
{
if ( !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ) )
@@ -147,9 +166,15 @@ FuzzyIndex::search( const QString& table, const QString& name )
if ( score > 0.05 )
{
resultsmap.insert( id, score );
// qDebug() << "Hitres:" << result << id << score << table << name;
// qDebug() << "Hitres:" << result << id << score << table << name;
}
}
}
catch( CLuceneError& error )
{
qDebug() << "Caught CLucene error:" << error.what();
Q_ASSERT( false );
}
return resultsmap;
}