Skip to content

Commit 026d504

Browse files
committed
Resolved FIXME comments: throw IAE when failed to parse resource files.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1379128 13f79535-47bb-0310-9956-ffa450edef68
1 parent a078eee commit 026d504

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/main/java/org/apache/commons/codec/language/bm/Lang.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ public static Lang loadFromResource(String languageRulesResourceName, Languages
167167
String[] parts = line.split("\\s+");
168168

169169
if (parts.length != 3) {
170-
// FIXME: consider throwing an IllegalStateException like in Rule
171-
// System.err.println("Warning: malformed line '" + rawLine + "'");
172-
continue;
170+
throw new IllegalArgumentException("Malformed line '" + rawLine + "' in language resource '" +
171+
languageRulesResourceName + "'");
173172
}
174173

175174
Pattern pattern = Pattern.compile(parts[0]);

src/main/java/org/apache/commons/codec/language/bm/Rule.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,17 @@ private static List<Rule> parseRules(final Scanner scanner, final String locatio
358358
// include statement
359359
String incl = line.substring(HASH_INCLUDE.length()).trim();
360360
if (incl.contains(" ")) {
361-
// FIXME: consider throwing an IllegalStateException like in parsePhonemeExpr
362-
// System.err.println("Warning: malformed import statement: " + rawLine);
361+
throw new IllegalArgumentException("Malformed import statement '" + rawLine + "' in " +
362+
location);
363363
} else {
364364
lines.addAll(parseRules(createScanner(incl), location + "->" + incl));
365365
}
366366
} else {
367367
// rule
368368
String[] parts = line.split("\\s+");
369369
if (parts.length != 4) {
370-
// FIXME: consider throwing an IllegalStateException like in parsePhonemeExpr
371-
// System.err.println("Warning: malformed rule statement split into " + parts.length +
372-
// " parts: " + rawLine);
370+
throw new IllegalArgumentException("Malformed rule statement split into " + parts.length +
371+
" parts: " + rawLine + " in " + location);
373372
} else {
374373
try {
375374
String pat = stripQuotes(parts[0]);
@@ -393,7 +392,8 @@ public String toString() {
393392
};
394393
lines.add(r);
395394
} catch (IllegalArgumentException e) {
396-
throw new IllegalStateException("Problem parsing line " + currentLine, e);
395+
throw new IllegalStateException("Problem parsing line '" + currentLine + "' in " +
396+
location, e);
397397
}
398398
}
399399
}

0 commit comments

Comments
 (0)