ignore templates that cannot be loaded
@@ -100,9 +100,9 @@ public class Main {
}
@VisibleForTesting
- static String readQuestionTemplate(Path file, Map<String, String> templates) {
+ static String readQuestionTemplate(Path file, Map<String, String> templates)
+ throws JSONException, IOException {
String questionText = CommonUtil.readFile(file);
- try {
JSONObject questionObj = new JSONObject(questionText);
if (questionObj.has(BfConsts.PROP_INSTANCE) && !questionObj.isNull(BfConsts.PROP_INSTANCE)) {
JSONObject instanceDataObj = questionObj.getJSONObject(BfConsts.PROP_INSTANCE);
@@ -122,9 +122,6 @@ public class Main {
} else {
throw new BatfishException(String.format("Question in file:%s has no instance name", file));
}
- } catch (JSONException | IOException e) {
- throw new BatfishException("Failed to process question", e);
- }
}
@VisibleForTesting
@@ -139,7 +136,13 @@ public class Main {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
String filename = file.getFileName().toString();
if (filename.endsWith(".json")) {
+ try {
readQuestionTemplate(file, templates);
+ } catch (Exception e) {
+ _logger.errorf(
+ "Failed to read question template from '%s': %s",
+ file, Throwables.getStackTraceAsString(e));
+ }
}
return FileVisitResult.CONTINUE;
}
