"Split" ReaderException into subclasses to enable more useful error reporting
[zxing.git] / core / src / com / google / zxing / oned / UPCEReader.java
index 3dd95a4..ef74b97 100644 (file)
@@ -17,7 +17,9 @@
 package com.google.zxing.oned;
 
 import com.google.zxing.BarcodeFormat;
-import com.google.zxing.ReaderException;
+import com.google.zxing.ChecksumException;
+import com.google.zxing.FormatException;
+import com.google.zxing.NotFoundException;
 import com.google.zxing.common.BitArray;
 
 /**
@@ -53,7 +55,7 @@ public final class UPCEReader extends UPCEANReader {
   }
 
   protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result)
-      throws ReaderException {
+      throws NotFoundException {
     int[] counters = decodeMiddleCounters;
     counters[0] = 0;
     counters[1] = 0;
@@ -80,16 +82,16 @@ public final class UPCEReader extends UPCEANReader {
     return rowOffset;
   }
 
-  protected int[] decodeEnd(BitArray row, int endStart) throws ReaderException {
+  protected int[] decodeEnd(BitArray row, int endStart) throws NotFoundException {
     return findGuardPattern(row, endStart, true, MIDDLE_END_PATTERN);
   }
 
-  protected boolean checkChecksum(String s) throws ReaderException {
+  protected boolean checkChecksum(String s) throws FormatException, ChecksumException {
     return super.checkChecksum(convertUPCEtoUPCA(s));
   }
 
   private static void determineNumSysAndCheckDigit(StringBuffer resultString, int lgPatternFound)
-      throws ReaderException {
+      throws NotFoundException {
 
     for (int numSys = 0; numSys <= 1; numSys++) {
       for (int d = 0; d < 10; d++) {
@@ -100,7 +102,7 @@ public final class UPCEReader extends UPCEANReader {
         }
       }
     }
-    throw ReaderException.getInstance();
+    throw NotFoundException.getNotFoundInstance();
   }
 
   BarcodeFormat getBarcodeFormat() {