From: James Procter Date: Wed, 7 Jun 2023 16:13:55 +0000 (+0100) Subject: JAL-4195 catch thrown exceptions (if any) during image export and report as an error. X-Git-Tag: Release_2_11_4_0~213^2~22^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f754db87420bc03f4665bda29593aab07d186dcb;p=jalview.git JAL-4195 catch thrown exceptions (if any) during image export and report as an error. --- diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 64c1e72..b9c04f5 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -44,6 +44,7 @@ import jalview.io.FileLoader; import jalview.io.HtmlSvgOutput; import jalview.io.IdentifyFile; import jalview.io.NewickFile; +import jalview.io.exceptions.ImageOutputException; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.structure.StructureImportSettings.TFType; @@ -737,7 +738,7 @@ public class Commands Cache.setProperty("EXPORT_EMBBED_BIOJSON", "false"); Console.info("Writing " + file); - + try { switch (type) { @@ -786,6 +787,9 @@ public class Commands + "' not known. Ignoring"); break; } + } catch (Exception ioex) { + Console.warn("Unexpected error during export",ioex); + } } } return true; diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index ed80eb9..d659e2a 100644 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -34,6 +34,7 @@ import jalview.datamodel.AlignExportSettingsAdapter; import jalview.datamodel.AlignmentExportData; import jalview.gui.AlignmentPanel; import jalview.gui.IProgressIndicator; +import jalview.io.exceptions.ImageOutputException; import jalview.util.MessageManager; public abstract class HTMLOutput implements Runnable @@ -302,12 +303,12 @@ public abstract class HTMLOutput implements Runnable return generatedFile; } - public void exportHTML(String outputFile) + public void exportHTML(String outputFile) throws ImageOutputException { exportHTML(outputFile, null); } - public void exportHTML(String outputFile, String renderer) + public void exportHTML(String outputFile, String renderer) throws ImageOutputException { setProgressMessage(MessageManager.formatMessage( "status.exporting_alignment_as_x_file", getDescription())); @@ -358,5 +359,5 @@ public abstract class HTMLOutput implements Runnable } // used to pass an option such as render to run - public abstract void run(String string); + public abstract void run(String string) throws ImageOutputException; } \ No newline at end of file diff --git a/src/jalview/io/exceptions/ImageOutputException.java b/src/jalview/io/exceptions/ImageOutputException.java new file mode 100644 index 0000000..bf06494 --- /dev/null +++ b/src/jalview/io/exceptions/ImageOutputException.java @@ -0,0 +1,36 @@ +package jalview.io.exceptions; + +/** + * wrapper for passing error messages and exceptions back to UI when image io goes wrong + * @author jprocter + * + */ +public class ImageOutputException extends Exception +{ + + public ImageOutputException() + { + } + + public ImageOutputException(String message) + { + super(message); + } + + public ImageOutputException(Throwable cause) + { + super(cause); + } + + public ImageOutputException(String message, Throwable cause) + { + super(message, cause); + } + + public ImageOutputException(String message, Throwable cause, + boolean enableSuppression, boolean writableStackTrace) + { + super(message, cause, enableSuppression, writableStackTrace); + } + +}