From a7ea3b9727e69934945ed7130e6b32e7d5ee0210 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 28 Oct 2022 08:16:13 -0500 Subject: [PATCH 1/2] HandleExtraFileType: catch Bio-Formats exceptions And eat the exception, unless we are in debug mode. See: https://imagesc.zulipchat.com/#narrow/stream/327470-Mastodon/topic/Release.20beta-25/near/306615130 --- src/main/java/HandleExtraFileTypes.java | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/HandleExtraFileTypes.java b/src/main/java/HandleExtraFileTypes.java index 713abb6..77c6f4a 100644 --- a/src/main/java/HandleExtraFileTypes.java +++ b/src/main/java/HandleExtraFileTypes.java @@ -521,20 +521,22 @@ private ImagePlus openImage(final String directory, final String name, (IJ.getVersion().compareTo("1.38j") < 0 || !IJ.redirectingErrorMessages()) && (new File(path).exists())) { - final Object loci = IJ.runPlugIn("loci.plugins.LociImporter", path); - if (loci != null) { - // plugin exists and was launched - try { - // check whether plugin was successful - final Class c = loci.getClass(); - final boolean success = c.getField("success").getBoolean(loci); - final boolean canceled = c.getField("canceled").getBoolean(loci); - if (success || canceled) { - width = IMAGE_OPENED; - return null; + try { + final Object loci = IJ.runPlugIn("loci.plugins.LociImporter", path); + if (loci != null) { + // plugin exists and was launched + // check whether plugin was successful + final Class c = loci.getClass(); + final boolean success = c.getField("success").getBoolean(loci); + final boolean canceled = c.getField("canceled").getBoolean(loci); + if (success || canceled) { + width = IMAGE_OPENED; + return null; + } } } - catch (final Exception exc) {} + catch (final Exception exc) { + if (IJ.debugMode) IJ.handleException(exc); } } From 109274c1e76e1e7669a8bdc131700d2521c18d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 31 Oct 2022 16:25:52 +0100 Subject: [PATCH 2/2] HandleExtraFileType: report after catching Bio-Formats exceptions So that the exception becomes visible to the user, at least. And handled if Fiji is in the debug mode. Continues: https://imagesc.zulipchat.com/#narrow/stream/327470-Mastodon/topic/Release.20beta-25/near/306615130 --- src/main/java/HandleExtraFileTypes.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/HandleExtraFileTypes.java b/src/main/java/HandleExtraFileTypes.java index 77c6f4a..b086cc9 100644 --- a/src/main/java/HandleExtraFileTypes.java +++ b/src/main/java/HandleExtraFileTypes.java @@ -536,6 +536,8 @@ private ImagePlus openImage(final String directory, final String name, } } catch (final Exception exc) { + IJ.log("Error opening the input in LociImporter who says:\n-----\n" + + exc.getMessage() + "\n-----"); if (IJ.debugMode) IJ.handleException(exc); } }