mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 12:52:34 +00:00
refactor to use exception helper factories
This commit is contained in:
@@ -105,7 +105,7 @@ impl<'a> Detector<'_> {
|
||||
|
||||
let moduleSize = self.calculateModuleSize(topLeft, topRight, bottomLeft);
|
||||
if moduleSize < 1.0 {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFoundEmpty());
|
||||
}
|
||||
let dimension = Self::computeDimension(topLeft, topRight, bottomLeft, moduleSize)?;
|
||||
let provisionalVersion = Version::getProvisionalVersionForDimension(dimension)?;
|
||||
@@ -147,7 +147,7 @@ impl<'a> Detector<'_> {
|
||||
alignmentPattern.as_ref(),
|
||||
dimension,
|
||||
)
|
||||
.ok_or(Exceptions::NotFoundException(None))?;
|
||||
.ok_or(Exceptions::notFoundEmpty())?;
|
||||
|
||||
let bits = Detector::sampleGrid(self.image, &transform, dimension)?;
|
||||
|
||||
@@ -160,7 +160,7 @@ impl<'a> Detector<'_> {
|
||||
if alignmentPattern.is_some() {
|
||||
points.push(
|
||||
alignmentPattern
|
||||
.ok_or(Exceptions::NotFoundException(None))?
|
||||
.ok_or(Exceptions::notFoundEmpty())?
|
||||
.into_rxing_result_point(),
|
||||
)
|
||||
}
|
||||
@@ -241,7 +241,7 @@ impl<'a> Detector<'_> {
|
||||
match dimension & 0x03 {
|
||||
0 => dimension += 1,
|
||||
2 => dimension -= 1,
|
||||
3 => return Err(Exceptions::NotFoundException(None)),
|
||||
3 => return Err(Exceptions::notFoundEmpty()),
|
||||
_ => {}
|
||||
}
|
||||
Ok(dimension as u32)
|
||||
@@ -428,13 +428,13 @@ impl<'a> Detector<'_> {
|
||||
let alignmentAreaLeftX = 0.max(estAlignmentX as i32 - allowance as i32) as u32;
|
||||
let alignmentAreaRightX = (self.image.getWidth() - 1).min(estAlignmentX + allowance);
|
||||
if ((alignmentAreaRightX - alignmentAreaLeftX) as f32) < overallEstModuleSize * 3.0 {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFoundEmpty());
|
||||
}
|
||||
|
||||
let alignmentAreaTopY = 0.max(estAlignmentY as i32 - allowance as i32) as u32;
|
||||
let alignmentAreaBottomY = (self.image.getHeight() - 1).min(estAlignmentY + allowance);
|
||||
if alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize as u32 * 3 {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFoundEmpty());
|
||||
}
|
||||
|
||||
let mut alignmentFinder = AlignmentPatternFinder::new(
|
||||
|
||||
Reference in New Issue
Block a user