diff --git a/aard.cc b/aard.cc index 4c993d90..914c233f 100644 --- a/aard.cc +++ b/aard.cc @@ -404,6 +404,11 @@ void AardDictionary::loadArticle( quint32 address, articleBody.resize( articleSize ); df.read( &articleBody.front(), articleSize ); } + catch( std::exception &ex ) + { + qWarning( "AARD: Failed loading article from \"%s\", reason: %s\n", getName().c_str(), ex.what() ); + break; + } catch(...) { break; diff --git a/bgl.cc b/bgl.cc index dff23782..979e9d6b 100644 --- a/bgl.cc +++ b/bgl.cc @@ -746,8 +746,9 @@ void BglArticleRequest::run() articlesIncluded.insert( chain[ x ].articleOffset ); } // try - catch( Utf8::exCantDecode ) + catch( std::exception &ex ) { + qWarning( "BGL: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() ); } } diff --git a/dsl.cc b/dsl.cc index c1b299c1..b50ec94a 100644 --- a/dsl.cc +++ b/dsl.cc @@ -1238,60 +1238,70 @@ void DslArticleRequest::run() wstring articleBody; unsigned headwordIndex; - dict.loadArticle( chain[ x ].articleOffset, wordCaseFolded, tildeValue, - displayedHeadword, headwordIndex, articleBody ); - - if ( !articlesIncluded.insert( std::make_pair( chain[ x ].articleOffset, - headwordIndex ) ).second ) - continue; // We already have this article in the body. - - dict.articleNom += 1; - - if( displayedHeadword.empty() || isDslWs( displayedHeadword[ 0 ] ) ) - displayedHeadword = word; // Special case - insided card - string articleText, articleAfter; - articleText += ""; - articleText += "
"; - if( articleText.compare( articleText.size() - 4, 4, "

" ) == 0 ) - articleText.insert( articleText.size() - 4, " " + button ); - else - articleText += button; - } + dict.loadArticle( chain[ x ].articleOffset, wordCaseFolded, tildeValue, + displayedHeadword, headwordIndex, articleBody ); - articleText += articleAfter; + if ( !articlesIncluded.insert( std::make_pair( chain[ x ].articleOffset, + headwordIndex ) ).second ) + continue; // We already have this article in the body. + + dict.articleNom += 1; + + if( displayedHeadword.empty() || isDslWs( displayedHeadword[ 0 ] ) ) + displayedHeadword = word; // Special case - insided card + + articleText += ""; + articleText += "
"; + if( articleText.compare( articleText.size() - 4, 4, "

" ) == 0 ) + articleText.insert( articleText.size() - 4, " " + button ); + else + articleText += button; + } + + articleText += articleAfter; + } + catch( std::exception &ex ) + { + qWarning( "DSL: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() ); + articleText = string( "" ) + + string( QObject::tr( "Article loading error" ).toUtf8().constData() ) + + ""; + } Mutex::Lock _( dataMutex ); @@ -1472,13 +1482,11 @@ void DslResourceRequest::run() hasAnyData = true; } - catch( File::Ex & ) + catch( std::exception &ex ) { - // No such resource -- we don't set the hasAnyData flag then - } - catch( Utf8::exCantDecode ) - { - // Failed to decode some utf8 -- probably the resource name is no good + qWarning( "DSL: Failed loading resource \"%s\" for \"%s\", reason: %s\n", + resourceName.c_str(), dict.getName().c_str(), ex.what() ); + // Resource not loaded -- we don't set the hasAnyData flag then } finish(); diff --git a/hunspell.cc b/hunspell.cc index 31984b60..066f39cc 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -283,6 +283,10 @@ void HunspellArticleRequest::run() { qWarning( "Hunspell: charset convertion error, no processing's done: %s\n", e.what() ); } + catch( std::exception & e ) + { + qWarning( "Hunspell: error: %s\n", e.what() ); + } if ( suggestions ) { diff --git a/iconv.hh b/iconv.hh index 421e6d65..5553ebdf 100644 --- a/iconv.hh +++ b/iconv.hh @@ -17,7 +17,7 @@ public: DEF_EX( Ex, "Iconv exception", std::exception ) DEF_EX_STR( exCantInit, "Can't initialize iconv conversion:", Ex ) - DEF_EX( exIncorrectSeq, "Invalid character sequence encountered during character convesion", Ex ) + DEF_EX( exIncorrectSeq, "Invalid character sequence encountered during character conversion", Ex ) DEF_EX( exPrematureEnd, "Character sequence ended prematurely during character conversion", Ex ) DEF_EX_STR( exOther, "An error has occured during character conversion:", Ex ) diff --git a/sdict.cc b/sdict.cc index 9d470c34..2cefd81b 100644 --- a/sdict.cc +++ b/sdict.cc @@ -464,25 +464,33 @@ void SdictArticleRequest::run() string headword, articleText; headword = chain[ x ].word; - dict.loadArticle( chain[ x ].articleOffset, articleText ); - // Ok. Now, does it go to main articles, or to alternate ones? We list - // main ones first, and alternates after. + try + { + dict.loadArticle( chain[ x ].articleOffset, articleText ); - // We do the case-folded comparison here. + // Ok. Now, does it go to main articles, or to alternate ones? We list + // main ones first, and alternates after. - wstring headwordStripped = - Folding::applySimpleCaseOnly( Utf8::decode( headword ) ); + // We do the case-folded comparison here. - multimap< wstring, pair< string, string > > & mapToUse = - ( wordCaseFolded == headwordStripped ) ? - mainArticles : alternateArticles; + wstring headwordStripped = + Folding::applySimpleCaseOnly( Utf8::decode( headword ) ); - mapToUse.insert( pair< wstring, pair< string, string > >( - Folding::applySimpleCaseOnly( Utf8::decode( headword ) ), - pair< string, string >( headword, articleText ) ) ); + multimap< wstring, pair< string, string > > & mapToUse = + ( wordCaseFolded == headwordStripped ) ? + mainArticles : alternateArticles; - articlesIncluded.insert( chain[ x ].articleOffset ); + mapToUse.insert( pair< wstring, pair< string, string > >( + Folding::applySimpleCaseOnly( Utf8::decode( headword ) ), + pair< string, string >( headword, articleText ) ) ); + + articlesIncluded.insert( chain[ x ].articleOffset ); + } + catch( std::exception &ex ) + { + qWarning( "SDict: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() ); + } } if ( mainArticles.empty() && alternateArticles.empty() ) diff --git a/stardict.cc b/stardict.cc index 2dc54e67..0aef84c6 100644 --- a/stardict.cc +++ b/stardict.cc @@ -396,7 +396,7 @@ void StardictDictionary::loadArticle( uint32_t address, else if ( !size ) { - FDPRINTF( stderr, "Warning: short entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: short entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -410,7 +410,7 @@ void StardictDictionary::loadArticle( uint32_t address, if ( size < entrySize ) { - FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -431,7 +431,7 @@ void StardictDictionary::loadArticle( uint32_t address, { if ( size < sizeof( uint32_t ) ) { - FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -445,7 +445,7 @@ void StardictDictionary::loadArticle( uint32_t address, if ( size < entrySize ) { - FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -456,8 +456,8 @@ void StardictDictionary::loadArticle( uint32_t address, } else { - FDPRINTF( stderr, "Warning: non-alpha entry type 0x%x for the word %s encountered.\n", - type, headword.c_str() ); + qWarning( "Stardict: non-alpha entry type 0x%x for the word %s encountered in \"%s\".\n", + type, headword.c_str(), getName().c_str() ); break; } } @@ -474,7 +474,7 @@ void StardictDictionary::loadArticle( uint32_t address, if ( size < len + 2 ) { - FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -489,7 +489,7 @@ void StardictDictionary::loadArticle( uint32_t address, // An entry which havs its size before contents if ( size < sizeof( uint32_t ) + 1 ) { - FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -501,7 +501,7 @@ void StardictDictionary::loadArticle( uint32_t address, if ( size < sizeof( uint32_t ) + 1 + entrySize ) { - FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() ); + qWarning( "Stardict: malformed entry for the word %s encountered in \"%s\".\n", headword.c_str(), getName().c_str() ); break; } @@ -512,8 +512,8 @@ void StardictDictionary::loadArticle( uint32_t address, } else { - FDPRINTF( stderr, "Warning: non-alpha entry type 0x%x for the word %s encountered.\n", - (unsigned)*ptr, headword.c_str() ); + qWarning( "Stardict: non-alpha entry type 0x%x for the word %s encountered in \"%s\".\n", + (unsigned)*ptr, headword.c_str(), getName().c_str() ); break; } } @@ -1115,13 +1115,11 @@ void StardictResourceRequest::run() hasAnyData = true; } - catch( File::Ex & ) + catch( std::exception &ex ) { - // No such resource -- we don't set the hasAnyData flag then - } - catch( Utf8::exCantDecode ) - { - // Failed to decode some utf8 -- probably the resource name is no good + qWarning( "Stardict: Failed loading resource \"%s\" for \"%s\", reason: %s\n", + resourceName.c_str(), dict.getName().c_str(), ex.what() ); + // Resource not loaded -- we don't set the hasAnyData flag then } catch( ... ) { diff --git a/xdxf.cc b/xdxf.cc index 9acfc91f..92d4f490 100644 --- a/xdxf.cc +++ b/xdxf.cc @@ -443,25 +443,33 @@ void XdxfArticleRequest::run() string headword, articleText; headword = chain[ x ].word; - dict.loadArticle( chain[ x ].articleOffset, articleText ); - // Ok. Now, does it go to main articles, or to alternate ones? We list - // main ones first, and alternates after. + try + { + dict.loadArticle( chain[ x ].articleOffset, articleText ); - // We do the case-folded comparison here. + // Ok. Now, does it go to main articles, or to alternate ones? We list + // main ones first, and alternates after. - wstring headwordStripped = - Folding::applySimpleCaseOnly( Utf8::decode( headword ) ); + // We do the case-folded comparison here. - multimap< wstring, pair< string, string > > & mapToUse = - ( wordCaseFolded == headwordStripped ) ? - mainArticles : alternateArticles; + wstring headwordStripped = + Folding::applySimpleCaseOnly( Utf8::decode( headword ) ); - mapToUse.insert( pair< wstring, pair< string, string > >( - Folding::applySimpleCaseOnly( Utf8::decode( headword ) ), - pair< string, string >( headword, articleText ) ) ); + multimap< wstring, pair< string, string > > & mapToUse = + ( wordCaseFolded == headwordStripped ) ? + mainArticles : alternateArticles; - articlesIncluded.insert( chain[ x ].articleOffset ); + mapToUse.insert( pair< wstring, pair< string, string > >( + Folding::applySimpleCaseOnly( Utf8::decode( headword ) ), + pair< string, string >( headword, articleText ) ) ); + + articlesIncluded.insert( chain[ x ].articleOffset ); + } + catch( std::exception &ex ) + { + qWarning( "XDXF: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() ); + } } if ( mainArticles.empty() && alternateArticles.empty() ) @@ -983,13 +991,11 @@ void XdxfResourceRequest::run() hasAnyData = true; } - catch( File::Ex & ) + catch( std::exception &ex ) { - // No such resource -- we don't set the hasAnyData flag then - } - catch( Utf8::exCantDecode ) - { - // Failed to decode some utf8 -- probably the resource name is no good + qWarning( "XDXF: Failed loading resource \"%s\" for \"%s\", reason: %s\n", + resourceName.c_str(), dict.getName().c_str(), ex.what() ); + // Resource not loaded -- we don't set the hasAnyData flag then } finish(); diff --git a/zim.cc b/zim.cc index 6d5d9594..4be5dc96 100644 --- a/zim.cc +++ b/zim.cc @@ -936,13 +936,11 @@ void ZimResourceRequest::run() hasAnyData = true; } - catch( File::Ex & ) + catch( std::exception &ex ) { - // No such resource -- we don't set the hasAnyData flag then - } - catch( Utf8::exCantDecode ) - { - // Failed to decode some utf8 -- probably the resource name is no good + qWarning( "ZIM: Failed loading resource \"%s\" from \"%s\", reason: %s\n", + resourceName.c_str(), dict.getName().c_str(), ex.what() ); + // Resource not loaded -- we don't set the hasAnyData flag then } finish();