Skip to content

Commit

Permalink
throw exception rather than calling system exit
Browse files Browse the repository at this point in the history
  • Loading branch information
trautmane committed May 7, 2024
1 parent a0308de commit 4d557f8
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public final Void call() throws IOException, InterruptedException, ExecutionExce
final String minHeightField = fieldGroup + "/min";
final String minHeightFieldOut = fieldGroupOut + "/min";

checkIfGroupExists(sourceN5, minHeightField);
checkIfGroupDoesntExist(sourceN5, minHeightFieldOut);
confirmGroupExists(sourceN5, minHeightField);
confirmGroupDoesntExist(sourceN5, minHeightFieldOut);

System.out.println("LOADING height field " + n5Path + minHeightField);
RandomAccessibleInterval<FloatType> heightFieldSource = N5Utils.open(sourceN5, minHeightField);
Expand All @@ -103,8 +103,8 @@ public final Void call() throws IOException, InterruptedException, ExecutionExce
final String maxHeightField = fieldGroup + "/max";
final String maxHeightFieldOut = fieldGroupOut + "/max";

checkIfGroupExists(sourceN5, maxHeightField);
checkIfGroupDoesntExist(sourceN5, maxHeightFieldOut);
confirmGroupExists(sourceN5, maxHeightField);
confirmGroupDoesntExist(sourceN5, maxHeightFieldOut);

System.out.println("LOADING height field " + n5Path + maxHeightField);
heightFieldSource = N5Utils.open(sourceN5, maxHeightField);
Expand Down Expand Up @@ -142,17 +142,17 @@ public final Void call() throws IOException, InterruptedException, ExecutionExce
return null;
}

private static void checkIfGroupExists(final N5Reader n5, final String dataset) {
private static void confirmGroupExists(final N5Reader n5, final String dataset)
throws IllegalArgumentException {
if (!n5.exists(dataset)) {
System.out.println("heightfield dataset does not exist: " + n5 + dataset);
System.exit(0);
throw new IllegalArgumentException("heightfield dataset does not exist: " + n5 + dataset);
}
}

private static void checkIfGroupDoesntExist(final N5Reader n5, final String dataset) {
private static void confirmGroupDoesntExist(final N5Reader n5, final String dataset)
throws IllegalArgumentException {
if (n5.exists(dataset)) {
System.out.println("heightfield dataset already exists: " + n5 + dataset);
System.exit(0);
throw new IllegalArgumentException("heightfield dataset already exists: " + n5 + dataset);
}
}
}

0 comments on commit 4d557f8

Please sign in to comment.