Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting for VcfToLuceneIndexer #300

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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