From a8d23b609ddf5168b64251212e132c30bdf4acef Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 31 Mar 2019 05:27:25 -0400 Subject: [PATCH] In qrcode, use the more specific NotFoundException. NotFound is the *typical* case for a QR code reader. ReaderException covers a lot of other genuinely exceptional cases though. It is useful to distinguish them. --- core/src/zxing/MultiFormatReader.cpp | 3 ++- core/src/zxing/multi/GenericMultipleBarcodeReader.cpp | 4 ++-- core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp | 3 ++- .../multi/qrcode/detector/MultiFinderPatternFinder.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/zxing/MultiFormatReader.cpp b/core/src/zxing/MultiFormatReader.cpp index fd21373..581dd78 100644 --- a/core/src/zxing/MultiFormatReader.cpp +++ b/core/src/zxing/MultiFormatReader.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using zxing::Ref; using zxing::Result; @@ -118,7 +119,7 @@ Ref MultiFormatReader::decodeInternal(Ref image) { // continue } } - throw ReaderException("No code detected"); + throw NotFoundException("No code detected"); } MultiFormatReader::~MultiFormatReader() {} diff --git a/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp b/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp index 5ab98a2..0a17e84 100644 --- a/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp +++ b/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include #include using std::vector; @@ -39,7 +39,7 @@ vector > GenericMultipleBarcodeReader::decodeMultiple(Ref > results; doDecodeMultiple(image, hints, results, 0, 0, 0); if (results.empty()){ - throw ReaderException("No code detected"); + throw NotFoundException("No code detected"); } return results; } diff --git a/core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp b/core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp index 05c5cbe..306e4b2 100644 --- a/core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp +++ b/core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -49,7 +50,7 @@ std::vector > QRCodeMultiReader::decodeMultiple(Ref im } } if (results.empty()){ - throw ReaderException("No code detected"); + throw NotFoundException("No code detected"); } return results; } diff --git a/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp b/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp index edc825f..f3f7dc1 100644 --- a/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +++ b/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include using std::abs; using std::min; @@ -27,7 +27,7 @@ using std::sort; using std::vector; using zxing::Ref; using zxing::BitMatrix; -using zxing::ReaderException; +using zxing::NotFoundException; using zxing::qrcode::FinderPattern; using zxing::qrcode::FinderPatternInfo; using zxing::multi::MultiFinderPatternFinder; @@ -142,7 +142,7 @@ vector > > MultiFinderPatternFinder::selectBestPattern if (size < 3) { // Couldn't find enough finder patterns - throw ReaderException("No code detected"); + throw NotFoundException("No code detected"); } vector > > results; @@ -230,7 +230,7 @@ vector > > MultiFinderPatternFinder::selectBestPattern } // end iterate p1 if (results.empty()){ // Nothing found! - throw ReaderException("No code detected"); + throw NotFoundException("No code detected"); } return results; }