Skip to content

Commit

Permalink
Improve error reporting for VcfToLuceneIndexer (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber authored Jan 4, 2024
1 parent dbd365e commit 6f9c818
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ else if (line.getCountType() == VCFHeaderLineCount.INTEGER || line.getCountType(
// should never reach this
throw new GATKException("Attempted to parse a numeric value into something other than Double/Integer. This should never occur.");
} catch (Exception e) {
possiblyReportBadValue(key, valueStr);
possiblyReportBadValue(e, key, valueStr);
return null;
}
}
else {
possiblyReportBadValue(key, valueStr);
possiblyReportBadValue(null, key, valueStr);
return null;
}
}
Expand All @@ -319,16 +319,16 @@ else if (clazz == Integer.class) {
throw new GATKException("Attempted to parse a numeric value into something other than Double/Integer. This should never occur.");
}
catch (Exception e) {
possiblyReportBadValue(key, valueStr);
possiblyReportBadValue(e, key, valueStr);
return null;
}
}
}

private final Set<String> keysWithErrors = new HashSet<>();

private void possiblyReportBadValue(String key, Object fieldValue) {
String message = "Unable to parse numeric value for field: " + key + ", was: <" + fieldValue + ">";
private void possiblyReportBadValue(@Nullable Exception e, String key, Object fieldValue) {
String message = "Unable to parse field: " + key + ", was: <" + fieldValue + ">. " + (e == null ? "" : e.getMessage());
if (stringency == ValidationStringency.STRICT) {
throw new GATKException(message);
}
Expand All @@ -345,7 +345,7 @@ synchronized private void addFieldToDocument(Document doc, VCFHeaderLineType var
stats.inspectValue(key, fieldValue);
}
catch (GATKException e) {
possiblyReportBadValue(key, fieldValue);
possiblyReportBadValue(e, key, fieldValue);
}

Collection<?> values = fieldValue instanceof Collection ? (Collection<?>) fieldValue : Collections.singleton(fieldValue);
Expand Down Expand Up @@ -377,6 +377,7 @@ synchronized private void addFieldToDocument(Document doc, VCFHeaderLineType var
}
}
case String -> doc.add(new TextField(key, String.valueOf(value), Field.Store.YES));
default -> possiblyReportBadValue(new Exception("VCF header type was not expected: " + variantHeaderLineType.name()), key, value);
}
}
catch (Exception e) {
Expand Down

0 comments on commit 6f9c818

Please sign in to comment.