mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
refactor to use exception helper factories
This commit is contained in:
@@ -199,7 +199,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if let Some(r) = result.getDecodedInformation() {
|
||||
Ok(r.clone())
|
||||
} else {
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFoundEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,8 +345,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if (5..15).contains(&fiveBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 5,
|
||||
char::from_u32('0' as u32 + fiveBitValue - 5)
|
||||
.ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32('0' as u32 + fiveBitValue - 5).ok_or(Exceptions::parseEmpty())?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -355,14 +354,14 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if (64..90).contains(&sevenBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 7,
|
||||
char::from_u32(sevenBitValue + 1).ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32(sevenBitValue + 1).ok_or(Exceptions::parseEmpty())?,
|
||||
));
|
||||
}
|
||||
|
||||
if (90..116).contains(&sevenBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 7,
|
||||
char::from_u32(sevenBitValue + 7).ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32(sevenBitValue + 7).ok_or(Exceptions::parseEmpty())?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -389,7 +388,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
250 => '?',
|
||||
251 => '_',
|
||||
252 => ' ',
|
||||
_ => return Err(Exceptions::FormatException(None)),
|
||||
_ => return Err(Exceptions::formatEmpty()),
|
||||
};
|
||||
|
||||
Ok(DecodedChar::new(pos + 8, c))
|
||||
@@ -424,8 +423,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if (5..15).contains(&fiveBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 5,
|
||||
char::from_u32('0' as u32 + fiveBitValue - 5)
|
||||
.ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32('0' as u32 + fiveBitValue - 5).ok_or(Exceptions::parseEmpty())?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -434,7 +432,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if (32..58).contains(&sixBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 6,
|
||||
char::from_u32(sixBitValue + 33).ok_or(Exceptions::ParseException(None))?,
|
||||
char::from_u32(sixBitValue + 33).ok_or(Exceptions::parseEmpty())?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -445,9 +443,9 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
61 => '.',
|
||||
62 => '/',
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||
return Err(Exceptions::illegalState(format!(
|
||||
"Decoding invalid alphanumeric value: {sixBitValue}"
|
||||
))))
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user