From 3cacd24691e70bf15ed15cb320b502bb30af5543 Mon Sep 17 00:00:00 2001 From: Enrique del Pino Date: Sun, 13 Oct 2024 15:10:55 +0200 Subject: [PATCH] Fixing CSVRecord.get when reference does not exist. Allowing for graceful failure when a mapping is not found on the data, allowing the execute to carry on ignoring the missing field, instead of stopping the process altogether. --- .../java/be/ugent/idlab/knows/dataio/record/CSVRecord.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/be/ugent/idlab/knows/dataio/record/CSVRecord.java b/src/main/java/be/ugent/idlab/knows/dataio/record/CSVRecord.java index ac9b843..cf3912f 100644 --- a/src/main/java/be/ugent/idlab/knows/dataio/record/CSVRecord.java +++ b/src/main/java/be/ugent/idlab/knows/dataio/record/CSVRecord.java @@ -80,7 +80,8 @@ public List get(String reference) { toDatabaseCase = reference; } if (!this.data.containsKey(toDatabaseCase)) { - throw new IllegalArgumentException(String.format("Mapping for %s not found, expected one of %s", toDatabaseCase, data.keySet())); + logger.warn("Mapping for {} not found, expected one of {}", toDatabaseCase, data.keySet()); + return List.of(); } String obj = this.data.get(toDatabaseCase);