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 2 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
25 changes: 22 additions & 3 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistic, can these be updated to use an indentation of two spaces - https://bio-formats.readthedocs.io/en/latest/developers/code-formatting.html#java

}
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);
}
}