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 1 commit
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
24 changes: 18 additions & 6 deletions components/bio-formats-tools/src/loci/formats/tools/ImageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import loci.formats.meta.MetadataStore;
import loci.formats.services.OMEXMLService;
import loci.formats.services.OMEXMLServiceImpl;
import loci.formats.UnknownFormatException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -1133,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 @@ -1144,19 +1144,31 @@ public static void main(String[] args) throws Exception {
newArgs[idx] = scanner.nextLine();
System.out.println("====% " + newArgs[idx]);
try {
new ImageInfo().testRead(newArgs);
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 (UnknownFormatException e) {
LOGGER.warn("Unknown file format: " + newArgs[idx]);
continue;
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);
}
}