Skip to content

Commit

Permalink
[misc] Cleaned up parsing error reporting to avoid spamming the log w…
Browse files Browse the repository at this point in the history
…ith "unsupported term" messages
  • Loading branch information
allasm committed Jan 17, 2018
1 parent 9d421af commit 61d3b70
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -144,6 +144,7 @@ private Set<Feature> convertFeatures(JSONObject json)
{
try {
if (json.has(ApiConfiguration.JSON_FEATURES)) {
Set<String> ignoredTerms = new HashSet<>();
Set<Feature> featureSet = new HashSet<>();
JSONArray featuresJson = (JSONArray) json.get(ApiConfiguration.JSON_FEATURES);
for (Object jsonFeatureUncast : featuresJson) {
Expand All @@ -152,7 +153,7 @@ private Set<Feature> convertFeatures(JSONObject json)
// TODO: throw an error if a term is not a supported one (HPO).
// TODO: maybe report an error, to be reviewed once spec is updated
if (!this.hpoTerm.matcher(id).matches()) {
LOGGER.error("Patient feature parser: ignoring unsupported term with ID [{}]", id);
ignoredTerms.add(id);
continue;
}
// resolve the given feature identifier to an human phenotype ontology feature ID
Expand All @@ -169,6 +170,12 @@ private Set<Feature> convertFeatures(JSONObject json)
Feature feature = new RemotePatientFeature(id, observed);
featureSet.add(feature);
}
if (ignoredTerms.size() > 0) {
// print all rejected terms together in order not to clutter the log
// (since some remote servers send a LOT of unsupported terms)
LOGGER.error("Patient feature parser: ignored {} unsupported terms: [{}]",
ignoredTerms.size(), String.join(",",ignoredTerms));
}
return featureSet;
}
} catch (Exception ex) {
Expand Down

0 comments on commit 61d3b70

Please sign in to comment.