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

Handle UnknownFormatException for batch processing multiple files. #4233

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Changes from 3 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
27 changes: 23 additions & 4 deletions components/bio-formats-tools/src/loci/formats/tools/ImageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ private void printDimension(String dim, int size, int effectiveSize,
public static void main(String[] args) throws Exception {
DebugTools.enableLogging("INFO");

int exitCode = 0;
List<String> argsList = Arrays.asList(args);
int idx = argsList.indexOf("-");

Expand All @@ -1141,15 +1142,33 @@ public static void main(String[] args) throws Exception {

while (scanner.hasNext()) {
newArgs[idx] = scanner.nextLine();
System.out.println("====% " + newArgs[idx]);
if (!new ImageInfo().testRead(newArgs)) System.exit(1);
System.out.println("====% " + newArgs[idx]);
try {
new ImageInfo().testRead(newArgs);
}
catch (FormatException e) {
LOGGER.error("Caught FormatException. " + e.getMessage());
exitCode = 1;
continue;
}
catch (IOException e) {
LOGGER.error("Caught IOException. " + e.getMessage());
exitCode = 1;
continue;
}
catch (ServiceException e) {
LOGGER.error("Caught ServiceException. " + e.getMessage());
exitCode = 1;
continue;
}
}
scanner.close();
}
else {
if (!new ImageInfo().testRead(args)) System.exit(1);
}
}
}

System.exit(exitCode);
}
}