Some more unhandled exceptions

This commit is contained in:
Abs62 2013-09-24 17:56:47 +04:00
parent 1a8bb0ae10
commit 4a414adfdc
9 changed files with 141 additions and 113 deletions

View file

@ -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;

3
bgl.cc
View file

@ -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() );
}
}

24
dsl.cc
View file

@ -1238,6 +1238,10 @@ void DslArticleRequest::run()
wstring articleBody;
unsigned headwordIndex;
string articleText, articleAfter;
try
{
dict.loadArticle( chain[ x ].articleOffset, wordCaseFolded, tildeValue,
displayedHeadword, headwordIndex, articleBody );
@ -1250,8 +1254,6 @@ void DslArticleRequest::run()
if( displayedHeadword.empty() || isDslWs( displayedHeadword[ 0 ] ) )
displayedHeadword = word; // Special case - insided card
string articleText, articleAfter;
articleText += "<span class=\"dsl_article\">";
articleText += "<div class=\"dsl_headwords\"";
if( dict.isFromLanguageRTL() )
@ -1292,6 +1294,14 @@ void DslArticleRequest::run()
}
articleText += articleAfter;
}
catch( std::exception &ex )
{
qWarning( "DSL: Failed loading article from \"%s\", reason: %s\n", dict.getName().c_str(), ex.what() );
articleText = string( "<span class=\"dsl_article\">" )
+ string( QObject::tr( "Article loading error" ).toUtf8().constData() )
+ "</span>";
}
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();

View file

@ -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 )
{

View file

@ -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 )

View file

@ -464,6 +464,9 @@ void SdictArticleRequest::run()
string headword, articleText;
headword = chain[ x ].word;
try
{
dict.loadArticle( chain[ x ].articleOffset, articleText );
// Ok. Now, does it go to main articles, or to alternate ones? We list
@ -484,6 +487,11 @@ void SdictArticleRequest::run()
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() )
{

View file

@ -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( ... )
{

18
xdxf.cc
View file

@ -443,6 +443,9 @@ void XdxfArticleRequest::run()
string headword, articleText;
headword = chain[ x ].word;
try
{
dict.loadArticle( chain[ x ].articleOffset, articleText );
// Ok. Now, does it go to main articles, or to alternate ones? We list
@ -463,6 +466,11 @@ void XdxfArticleRequest::run()
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();

10
zim.cc
View file

@ -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();