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

@@ -64,12 +64,12 @@ impl OneDReader for RSS14Reader {
if right.getCount() > 1 && self.checkChecksum(left, right) {
return self
.constructRXingResult(left, right)
.ok_or(Exceptions::IllegalStateException(None));
.ok_or(Exceptions::illegalStateEmpty());
}
}
}
}
Err(Exceptions::NotFoundException(None))
Err(Exceptions::notFoundEmpty())
}
}
impl Reader for RSS14Reader {
@@ -126,7 +126,7 @@ impl Reader for RSS14Reader {
Ok(result)
} else {
Err(Exceptions::NotFoundException(None))
Err(Exceptions::notFoundEmpty())
}
}
}
@@ -343,7 +343,7 @@ impl RSS14Reader {
if outsideChar {
if (oddSum & 0x01) != 0 || !(4..=12).contains(&oddSum) {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
let group = ((12 - oddSum) / 2) as usize;
let oddWidest = Self::OUTSIDE_ODD_WIDEST[group];
@@ -358,7 +358,7 @@ impl RSS14Reader {
))
} else {
if (evenSum & 0x01) != 0 || !(4..=10).contains(&evenSum) {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
let group = ((10 - evenSum) / 2) as usize;
let oddWidest = Self::INSIDE_ODD_WIDEST[group];
@@ -417,7 +417,7 @@ impl RSS14Reader {
isWhite = !isWhite;
}
}
Err(Exceptions::NotFoundException(None))
Err(Exceptions::notFoundEmpty())
}
fn parseFoundFinderPattern(
@@ -518,12 +518,12 @@ impl RSS14Reader {
1 => {
if oddParityBad {
if evenParityBad {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
decrementOdd = true;
} else {
if !evenParityBad {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
decrementEven = true;
}
@@ -531,12 +531,12 @@ impl RSS14Reader {
-1 => {
if oddParityBad {
if evenParityBad {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
incrementOdd = true;
} else {
if !evenParityBad {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
incrementEven = true;
}
@@ -544,7 +544,7 @@ impl RSS14Reader {
0 => {
if oddParityBad {
if !evenParityBad {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
// Both bad
if oddSum < evenSum {
@@ -555,15 +555,15 @@ impl RSS14Reader {
incrementEven = true;
}
} else if evenParityBad {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
}
_ => return Err(Exceptions::NotFoundException(None)),
_ => return Err(Exceptions::notFoundEmpty()),
}
if incrementOdd {
if decrementOdd {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
Self::increment(&mut self.oddCounts, &self.oddRoundingErrors);
}
@@ -572,7 +572,7 @@ impl RSS14Reader {
}
if incrementEven {
if decrementEven {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
Self::increment(&mut self.evenCounts, &self.evenRoundingErrors);
}