# HG changeset patch # User Diggory Hardy # Date 1240048953 -7200 # Node ID 0520cc00c0ccd633e5895362ede33f6bccfec3b8 # Parent 2934fcacbb97be29ed124d3faea084a5e4931880 Better error reporting for loading translations; avoided an infinite loop. diff -r 2934fcacbb97 -r 0520cc00c0cc mde/content/Translation.d --- a/mde/content/Translation.d Fri Apr 10 18:09:55 2009 +0200 +++ b/mde/content/Translation.d Sat Apr 18 12:02:33 2009 +0200 @@ -78,7 +78,6 @@ char[][] files = [loadedL10n]; // initial locale plus dependencies size_t read = 0; // index in files of next file to read while (read < files.length) { - logger.trace ("reading file {}", files[read]); try { MTTagReader reader = dataDir.makeMTTagReader ("L10n/"~files[read], PRIORITY.HIGH_LOW); bool isSecTag; @@ -110,20 +109,26 @@ // If the tag already exists, don't replace it if (sym in entries) continue; - Entry entry = deserialize!(Entry) (reader.tagData); - if (entry.name is null) { // This tag is invalid; ignore it - logger.error ("In L10n/{}.mtt: tag {} has no name", files[read], sym); - continue; - } - entries[sym] = entry; + try { + Entry entry = deserialize!(Entry) (reader.tagData); + if (entry.name is null) // This tag is invalid; ignore it + throw new ContentException ("Tag has no name"); + entries[sym] = entry; + } catch (Exception e) { + logger.error ("Exception reading L10n/{}.mtt:", files[read]); + logger.error ("While parsing tag {}", sym); + logger.error (e.msg); + continue; + } } } } while (reader.readTag (isSecTag)) - ++read; } catch (Exception e) { - logger.error ("Exception loading translation: {}", e.msg); + logger.error ("Exception reading L10n/{}.mtt:", files[read]); + logger.error (e.msg); } - } + ++read; // continue to next file regardless of whether this file was read successfully + } } /+ Getters for entries... not wanted now. diff -r 2934fcacbb97 -r 0520cc00c0cc mde/file/deserialize.d --- a/mde/file/deserialize.d Fri Apr 10 18:09:55 2009 +0200 +++ b/mde/file/deserialize.d Sat Apr 18 12:02:33 2009 +0200 @@ -306,7 +306,7 @@ ++i; } if (i >= pair.length) - throw new ParseException ("Invalid struct: encountered { ... KEY} (missing :DATA)"); + throw new ParseException ("Invalid KEY:DATA pair within struct: "~pair); size_t k = deserialize!(size_t) (pair[0..i]); // Note: could check no entry was already stored in temp.