Skip to content

Commit

Permalink
changed an exception catch that was resulting in a misleading erro me…
Browse files Browse the repository at this point in the history
…ssage in the logs. (#3648)
  • Loading branch information
landreev committed Apr 20, 2023
1 parent 4717311 commit 9545531
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/export/ExportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void exportFormat(Dataset dataset, String formatName) throws ExportExcept
if (e.getProviderName().equals(formatName)) {
DatasetVersion releasedVersion = dataset.getReleasedVersion();
if (releasedVersion == null) {
throw new IllegalStateException("No Released Version");
throw new ExportException("No published version found during export. " + dataset.getGlobalId().toString());
}
final JsonObjectBuilder datasetAsJsonBuilder = JsonPrinter.jsonAsDatasetDto(releasedVersion);
cacheExport(releasedVersion, formatName, datasetAsJsonBuilder.build(), e);
Expand All @@ -263,7 +263,18 @@ public void exportFormat(Dataset dataset, String formatName) throws ExportExcept
} catch (ServiceConfigurationError serviceError) {
throw new ExportException("Service configuration error during export. " + serviceError.getMessage());
} catch (IllegalStateException e) {
throw new ExportException("No published version found during export. " + dataset.getGlobalId().toString());
// IllegalStateException can potentially mean very different, and
// unexpected things. An exporter attempting to get a single primitive
// value from a fieldDTO that is in fact a Multiple and contains a
// json vector (this has happened, for example, when the code in the
// DDI exporter was not updated following a metadata fieldtype change),
// will result in IllegalStateException.
throw new ExportException("IllegalStateException caught when exporting "
+ formatName
+ " for dataset "
+ dataset.getGlobalId().toString()
+ "; may or may not be due to a mismatch between an exporter code and a metadata block update. "
+ e.getMessage());
}

//As with exportAll, we should update the lastexporttime for the dataset
Expand Down

0 comments on commit 9545531

Please sign in to comment.