Fix undocumented exception in SaveImageAwt
authorNiki Roo <niki@nikiroo.be>
Sun, 12 Aug 2018 20:40:07 +0000 (22:40 +0200)
committerNiki Roo <niki@nikiroo.be>
Sun, 12 Aug 2018 20:40:07 +0000 (22:40 +0200)
src/be/nikiroo/utils/ui/ImageUtilsAwt.java

index 0c69dc4482938ae02608be704167e23a8add13e0..3acbe55f9c23ad482d9ecc533bcd0e138fa8c92d 100644 (file)
@@ -36,7 +36,14 @@ public class ImageUtilsAwt extends ImageUtils {
                        // Some formats are not reliable
                        // Second chance: PNG
                        if (!ok && !format.equals("png")) {
-                               ok = ImageIO.write(image, "png", target);
+                               try {
+                                       ok = ImageIO.write(image, "png", target);
+                               } catch (IllegalArgumentException e) {
+                                       throw e;
+                               } catch (Exception e) {
+                                       throw new IOException("Undocumented exception occured, "
+                                                       + "converting to IOException", e);
+                               }
                        }
 
                        if (!ok) {