From 7e022edf66cc7783351c6c0af90c124568ff83ac Mon Sep 17 00:00:00 2001 From: srowen Date: Sat, 4 Oct 2008 10:12:17 +0000 Subject: [PATCH] Improved error message when file/URI is mistyped. git-svn-id: https://zxing.googlecode.com/svn/trunk@598 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../com/google/zxing/client/j2se/CommandLineRunner.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/javase/src/com/google/zxing/client/j2se/CommandLineRunner.java b/javase/src/com/google/zxing/client/j2se/CommandLineRunner.java index 10fb9086e..cac8e4ff7 100644 --- a/javase/src/com/google/zxing/client/j2se/CommandLineRunner.java +++ b/javase/src/com/google/zxing/client/j2se/CommandLineRunner.java @@ -26,6 +26,7 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.io.FileNotFoundException; import java.net.URI; import java.util.Hashtable; @@ -89,7 +90,12 @@ public final class CommandLineRunner { } private static boolean decode(URI uri, Hashtable hints) throws IOException { - BufferedImage image = ImageIO.read(uri.toURL()); + BufferedImage image; + try { + image = ImageIO.read(uri.toURL()); + } catch (IllegalArgumentException iae) { + throw new FileNotFoundException("Resource not found: " + uri); + } if (image == null) { System.err.println(uri.toString() + ": Could not load image"); return false;