Skip to content

Commit

Permalink
Handle UnknownFormatException for batch processing multiple files.
Browse files Browse the repository at this point in the history
When sequentially processing many files the unhandled exception terminates the program
and no further files will be processed that may still be readable. This commit catches
the exception, provides a warning message and continues processing.
  • Loading branch information
tstoeter committed Sep 9, 2024
1 parent e4ffbe8 commit dd500c8
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
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 @@ -1141,8 +1142,14 @@ 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 (UnknownFormatException e) {
LOGGER.warn("Unknown file format: " + newArgs[idx]);
continue;
}
}
scanner.close();
}
Expand Down

0 comments on commit dd500c8

Please sign in to comment.