diff --git a/src/dict/loaddictionaries.cc b/src/dict/loaddictionaries.cc index fc94b1939..23b60b589 100644 --- a/src/dict/loaddictionaries.cc +++ b/src/dict/loaddictionaries.cc @@ -44,6 +44,7 @@ #include #include +#include #include @@ -57,7 +58,6 @@ LoadDictionaries::LoadDictionaries( Config::Class const & cfg ): soundDirs( cfg.soundDirs ), hunspell( cfg.hunspell ), transliteration( cfg.transliteration ), - exceptionText( "Load did not finish" ), // Will be cleared upon success maxHeadwordSize( cfg.maxHeadwordSize ), maxHeadwordToExpand( cfg.maxHeadwordsToExpand ) { @@ -94,7 +94,15 @@ void LoadDictionaries::run() try { for ( const auto & path : paths ) { qDebug() << "handle path:" << path.path; - handlePath( path ); + try { + handlePath( path ); + } + catch ( const std::exception & e ) { + qWarning() << "Error handling path:" << path.path << "-" << e.what(); + //hold last exception message. + auto exception = "[" + path.path.toStdString() + "]:" + e.what(); + exceptionTexts << QString::fromUtf8( exception ); + } } // Make soundDirs @@ -129,11 +137,9 @@ void LoadDictionaries::run() dict->setFtsEnable( dictMetaData->fullindex.value() ); } } - - exceptionText.clear(); } catch ( std::exception & e ) { - exceptionText = e.what(); + exceptionTexts << QString::fromUtf8( e.what() ); } } @@ -228,8 +234,6 @@ void loadDictionaries( QWidget * parent, QMessageBox::critical( parent, QCoreApplication::translate( "LoadDictionaries", "Error loading dictionaries" ), QString::fromUtf8( loadDicts.getExceptionText().c_str() ) ); - - return; } dictionaries = loadDicts.getDictionaries(); diff --git a/src/dict/loaddictionaries.hh b/src/dict/loaddictionaries.hh index 8768a61d3..9600a3d11 100644 --- a/src/dict/loaddictionaries.hh +++ b/src/dict/loaddictionaries.hh @@ -9,6 +9,7 @@ #include #include +#include /// Use loadDictionaries() function below -- this is a helper thread class class LoadDictionaries: public QThread, public Dictionary::Initializing @@ -21,7 +22,7 @@ class LoadDictionaries: public QThread, public Dictionary::Initializing Config::Hunspell const & hunspell; Config::Transliteration const & transliteration; std::vector< sptr< Dictionary::Class > > dictionaries; - std::string exceptionText; + QStringList exceptionTexts; unsigned int maxHeadwordSize; unsigned int maxHeadwordToExpand; @@ -39,7 +40,7 @@ public: /// Empty string means to exception occurred std::string const & getExceptionText() const { - return exceptionText; + return exceptionTexts.join( "\n" ).toStdString(); }