refactor to use exception helper factories

This commit is contained in:
Vukašin Stepanović
2023-02-15 10:46:13 +00:00
parent 3e27279dc8
commit 722ce78fd0
132 changed files with 966 additions and 1132 deletions

View File

@@ -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(