From: srowen Date: Tue, 18 Nov 2008 21:15:30 +0000 (+0000) Subject: Replace IllegalStateException; still want to make it WriterException X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=57c7c83b72a6b528564d7cb2653a71b7e3434f58;p=zxing.git Replace IllegalStateException; still want to make it WriterException git-svn-id: http://zxing.googlecode.com/svn/trunk@721 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- diff --git a/core/src/com/google/zxing/qrcode/QRCodeWriter.java b/core/src/com/google/zxing/qrcode/QRCodeWriter.java index 25ca2b5a..f223935c 100644 --- a/core/src/com/google/zxing/qrcode/QRCodeWriter.java +++ b/core/src/com/google/zxing/qrcode/QRCodeWriter.java @@ -27,14 +27,12 @@ import java.util.Hashtable; public final class QRCodeWriter implements Writer { - public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, - int height) throws Exception { + public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, int height) { return encode(contents, format, width, height, null); } - public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, int height, - Hashtable hints) throws Exception { + public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, int height, Hashtable hints) { if (contents == null || contents.length == 0) { throw new IllegalArgumentException("Found empty contents"); @@ -55,7 +53,8 @@ public final class QRCodeWriter implements Writer { if (Encoder.Encode(new ByteArray(contents), errorCorrectionLevel, code)) { return renderResult(code, width, height); } else { - throw new IllegalStateException("Could not generate a QR Code"); + // TODO need a "WriterException" or something + throw new RuntimeException("Could not generate a QR Code"); } } diff --git a/core/src/com/google/zxing/qrcode/encoder/Debug.java b/core/src/com/google/zxing/qrcode/encoder/Debug.java index 69774603..1538eb3e 100644 --- a/core/src/com/google/zxing/qrcode/encoder/Debug.java +++ b/core/src/com/google/zxing/qrcode/encoder/Debug.java @@ -25,16 +25,18 @@ package com.google.zxing.qrcode.encoder; public class Debug { public static void LOG_ERROR(String message) { - throw new IllegalStateException(message); + // Can't use IllegalStateException unfortunately in J2ME + // TODO do something else with this anyway + throw new RuntimeException(message); } public static void LOG_INFO(String message) { - throw new IllegalStateException(message); + throw new RuntimeException(message); } public static void DCHECK(boolean condition) { if (!condition) { - throw new IllegalStateException(); + throw new RuntimeException(); } }