mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 04:42:35 +00:00
refactor to use exception helper factories
This commit is contained in:
@@ -66,7 +66,7 @@ impl UPCEANReader for EAN13Reader {
|
||||
)?;
|
||||
resultString.push(
|
||||
char::from_u32('0' as u32 + bestMatch as u32 % 10)
|
||||
.ok_or(Exceptions::ParseException(None))?,
|
||||
.ok_or(Exceptions::parseEmpty())?,
|
||||
);
|
||||
|
||||
rowOffset += counters.iter().sum::<u32>() as usize;
|
||||
@@ -90,8 +90,7 @@ impl UPCEANReader for EAN13Reader {
|
||||
let bestMatch =
|
||||
self.decodeDigit(row, &mut counters, rowOffset, &upc_ean_reader::L_PATTERNS)?;
|
||||
resultString.push(
|
||||
char::from_u32('0' as u32 + bestMatch as u32)
|
||||
.ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32('0' as u32 + bestMatch as u32).ok_or(Exceptions::parseEmpty())?,
|
||||
);
|
||||
|
||||
rowOffset += counters.iter().sum::<u32>() as usize;
|
||||
@@ -154,12 +153,11 @@ impl EAN13Reader {
|
||||
if lgPatternFound == Self::FIRST_DIGIT_ENCODINGS[d] {
|
||||
resultString.insert(
|
||||
0,
|
||||
char::from_u32('0' as u32 + d as u32)
|
||||
.ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32('0' as u32 + d as u32).ok_or(Exceptions::parseEmpty())?,
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFoundEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user