Skip to content

Commit

Permalink
Log file names on IOExceptions to console when ImageIO failed, #3
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 20, 2019
1 parent 0993c1f commit 36e3c96
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.shader.Framebuffer;
import org.apache.logging.log4j.Level;
import org.cyclops.iconexporter.IconExporter;
import org.lwjgl.BufferUtils;

import javax.imageio.ImageIO;
Expand Down Expand Up @@ -43,12 +45,17 @@ public static void exportImageFromScreenshot(File dir, String key, int guiWidth,

// Write the file
key = key.replaceAll(":", "__");
File file = new File(dir, key + ".png").getCanonicalFile();
try {
ImageIO.write(bufferedImage, "png", file);
} catch (NullPointerException e) {
e.printStackTrace();
throw new IOException("Error while writing the PNG image " + file);
File file = new File(dir, key + ".png").getCanonicalFile();
try {
ImageIO.write(bufferedImage, "png", file);
} catch (NullPointerException e) {
e.printStackTrace();
throw new IOException("Error while writing the PNG image " + file);
}
} catch (IOException e) {
IconExporter.clog(Level.ERROR, "Error while writing the PNG image for key " + key);
throw e;
}
}

Expand Down

0 comments on commit 36e3c96

Please sign in to comment.