Add better error reporting if a json spec can not be parsed

This commit is contained in:
Simon Willnauer 2014-01-13 17:15:57 +01:00
parent 268c2e2563
commit a66aead54a
1 changed files with 7 additions and 3 deletions

View File

@ -71,9 +71,13 @@ public class RestSpec {
RestSpec restSpec = new RestSpec(); RestSpec restSpec = new RestSpec();
for (String path : paths) { for (String path : paths) {
for (File jsonFile : FileUtils.findJsonSpec(optionalPathPrefix, path)) { for (File jsonFile : FileUtils.findJsonSpec(optionalPathPrefix, path)) {
try {
XContentParser parser = JsonXContent.jsonXContent.createParser(new FileInputStream(jsonFile)); XContentParser parser = JsonXContent.jsonXContent.createParser(new FileInputStream(jsonFile));
RestApi restApi = new RestApiParser().parse(parser); RestApi restApi = new RestApiParser().parse(parser);
restSpec.addApi(restApi); restSpec.addApi(restApi);
} catch (IOException ex) {
throw new IOException("Can't parse rest spec file: [" + jsonFile + "]", ex);
}
} }
} }
return restSpec; return restSpec;