Replace IllegalStateException; still want to make it WriterException

git-svn-id: https://zxing.googlecode.com/svn/trunk@721 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-11-18 21:15:30 +00:00
parent 919958c40f
commit 604a10e8e5
2 changed files with 9 additions and 8 deletions

View file

@ -27,14 +27,12 @@ import java.util.Hashtable;
public final class QRCodeWriter implements Writer { public final class QRCodeWriter implements Writer {
public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, int height) {
int height) throws Exception {
return encode(contents, format, width, height, null); return encode(contents, format, width, height, null);
} }
public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, int height, public ByteMatrix encode(byte[] contents, BarcodeFormat format, int width, int height, Hashtable hints) {
Hashtable hints) throws Exception {
if (contents == null || contents.length == 0) { if (contents == null || contents.length == 0) {
throw new IllegalArgumentException("Found empty contents"); throw new IllegalArgumentException("Found empty contents");
@ -55,7 +53,8 @@ public final class QRCodeWriter implements Writer {
if (Encoder.Encode(new ByteArray(contents), errorCorrectionLevel, code)) { if (Encoder.Encode(new ByteArray(contents), errorCorrectionLevel, code)) {
return renderResult(code, width, height); return renderResult(code, width, height);
} else { } 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");
} }
} }

View file

@ -25,16 +25,18 @@ package com.google.zxing.qrcode.encoder;
public class Debug { public class Debug {
public static void LOG_ERROR(String message) { 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) { public static void LOG_INFO(String message) {
throw new IllegalStateException(message); throw new RuntimeException(message);
} }
public static void DCHECK(boolean condition) { public static void DCHECK(boolean condition) {
if (!condition) { if (!condition) {
throw new IllegalStateException(); throw new RuntimeException();
} }
} }