Some small improvements in error handling based on exceptions observed at zxing.org

git-svn-id: https://zxing.googlecode.com/svn/trunk@538 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-07-30 21:58:17 +00:00
parent dbc1eebc49
commit 91b0ef1622
2 changed files with 12 additions and 0 deletions

View file

@ -74,6 +74,9 @@ public final class Detector {
FinderPattern bottomLeft = info.getBottomLeft();
float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
if (moduleSize < 1.0f) {
throw new ReaderException("Module size too small");
}
int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

View 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");