only:better error message

This commit is contained in:
rusefillc 2024-12-18 22:18:13 -05:00
parent 164bd90d61
commit db96fbecf7
2 changed files with 4 additions and 4 deletions

View File

@ -24,8 +24,8 @@ public class IniFileMetaInfoImpl implements IniFileMetaInfo {
public IniFileMetaInfoImpl(RawIniFile file) { public IniFileMetaInfoImpl(RawIniFile file) {
nPages = file.getSimpleIntegerProperty("nPages", 1);
try { try {
nPages = file.getSimpleIntegerProperty("nPages", 1);
ochBlockSize = file.getSimpleIntegerProperty("ochBlockSize"); ochBlockSize = file.getSimpleIntegerProperty("ochBlockSize");
blockingFactor = file.getSimpleIntegerProperty("blockingFactor", DEFAULT_BLOCKING_FACTOR); blockingFactor = file.getSimpleIntegerProperty("blockingFactor", DEFAULT_BLOCKING_FACTOR);

View File

@ -58,15 +58,15 @@ public class RawIniFile {
return lines; return lines;
} }
public int getSimpleIntegerProperty(String key) { public int getSimpleIntegerProperty(String key) throws MandatoryLineMissing {
Line line = asSet.get(key); Line line = asSet.get(key);
if (line == null) if (line == null)
throw new IllegalStateException("Line not found: " + key); throw new MandatoryLineMissing("Line not found: " + key);
String value = line.getTokens()[1]; String value = line.getTokens()[1];
return Integer.parseInt(value); return Integer.parseInt(value);
} }
public int getSimpleIntegerProperty(String key, int defaultValue) { public int getSimpleIntegerProperty(String key, int defaultValue) throws MandatoryLineMissing {
if (!asSet.containsKey(key)) if (!asSet.containsKey(key))
return defaultValue; return defaultValue;
return getSimpleIntegerProperty(key); return getSimpleIntegerProperty(key);