Some small improvements in error handling based on exceptions observed at zxing.org
[zxing.git] / zxingorg / src / com / google / zxing / web / DecodeServlet.java
index 0135bb3..e5ea042 100644 (file)
@@ -58,6 +58,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.net.SocketException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.UnknownHostException;
@@ -160,6 +161,14 @@ public final class DecodeServlet extends HttpServlet {
       } finally {
         is.close();
       }
+    } catch (IllegalArgumentException iae) {
+      // Thrown if hostname is bad or null
+      getRequest.abort();
+      response.sendRedirect("badurl.jspx");
+    } catch (SocketException se) {
+      // Thrown if hostname is bad or null
+      getRequest.abort();
+      response.sendRedirect("badurl.jspx");
     } catch (HttpException he) {
       getRequest.abort();
       response.sendRedirect("badurl.jspx");