Skip to content

Commit 925940d

Browse files
committed
add exception message
1 parent cd26c42 commit 925940d

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

src/main/java/fr/insee/genesis/domain/service/contextualvariable/ContextualVariableJsonService.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,29 @@ public SaveContextualVariablesReportDto saveContextualVariableFilesWithReport(
121121
while (it.hasNext()) {
122122
Path jsonFilePath = it.next();
123123

124-
Optional<String> type = processContextualVariableFileAndGetType(
125-
collectionInstrumentId,
126-
jsonFilePath
127-
);
128-
129-
if (type.isPresent()) {
130-
moveFile(collectionInstrumentId, mode, fileUtils, jsonFilePath.toString());
124+
try {
125+
Optional<String> type = processContextualVariableFileAndGetType(
126+
collectionInstrumentId,
127+
jsonFilePath
128+
);
131129

132-
files.add(new ContextualVariableFileReportDto(
133-
jsonFilePath.getFileName().toString(),
134-
type.get()
135-
));
130+
if (type.isPresent()) {
131+
moveFile(collectionInstrumentId, mode, fileUtils, jsonFilePath.toString());
132+
133+
files.add(new ContextualVariableFileReportDto(
134+
jsonFilePath.getFileName().toString(),
135+
type.get()
136+
));
137+
}
138+
} catch (GenesisException e) {
139+
throw new GenesisException(
140+
e.getStatus(),
141+
"Error while processing file '%s' : %s"
142+
.formatted(
143+
jsonFilePath.getFileName(),
144+
e.getMessage()
145+
)
146+
);
136147
}
137148
}
138149
} catch (NoSuchFileException nsfe) {

0 commit comments

Comments
 (0)