mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
Use thiserror for error handling with less boilerplate
This commit is contained in:
@@ -39,7 +39,7 @@ pub trait AbstractRSSReaderTrait: OneDReader {
|
||||
return Ok(value as u32);
|
||||
}
|
||||
}
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,13 +53,13 @@ pub fn buildBitArrayFromString(data: &str) -> Result<BitArray> {
|
||||
// for (int i = 0; i < dotsAndXs.length(); ++i) {
|
||||
if i % 9 == 0 {
|
||||
// spaces
|
||||
if dotsAndXs.chars().nth(i).ok_or(Exceptions::parse)? != ' ' {
|
||||
return Err(Exceptions::illegalStateWith("space expected"));
|
||||
if dotsAndXs.chars().nth(i).ok_or(Exceptions::PARSE)? != ' ' {
|
||||
return Err(Exceptions::illegal_state_with("space expected"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
let currentChar = dotsAndXs.chars().nth(i).ok_or(Exceptions::parse)?;
|
||||
let currentChar = dotsAndXs.chars().nth(i).ok_or(Exceptions::PARSE)?;
|
||||
if currentChar == 'X' || currentChar == 'x' {
|
||||
binary.set(counter);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ pub fn buildBitArrayFromStringWithoutSpaces(data: &str) -> Result<BitArray> {
|
||||
sb.push(' ');
|
||||
let mut i = 0;
|
||||
while i < 8 && current < dotsAndXs_length {
|
||||
sb.push(dotsAndXs.chars().nth(current).ok_or(Exceptions::parse)?);
|
||||
sb.push(dotsAndXs.chars().nth(current).ok_or(Exceptions::PARSE)?);
|
||||
current += 1;
|
||||
|
||||
i += 1;
|
||||
|
||||
@@ -152,7 +152,7 @@ pub fn createDecoder<'a>(
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Err(Exceptions::illegalStateWith(format!(
|
||||
Err(Exceptions::illegal_state_with(format!(
|
||||
"unknown decoder: {information}"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ impl AI01decoder for AI01392xDecoder<'_> {}
|
||||
impl AbstractExpandedDecoder for AI01392xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String> {
|
||||
if self.information.getSize() < Self::HEADER_SIZE + Self::GTIN_SIZE as usize {
|
||||
return Err(crate::Exceptions::notFound);
|
||||
return Err(crate::Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
@@ -39,7 +39,7 @@ impl AI01decoder for AI01393xDecoder<'_> {}
|
||||
impl AbstractExpandedDecoder for AI01393xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String> {
|
||||
if self.information.getSize() < Self::HEADER_SIZE + Self::GTIN_SIZE as usize {
|
||||
return Err(crate::Exceptions::notFound);
|
||||
return Err(crate::Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
@@ -57,7 +57,7 @@ impl AbstractExpandedDecoder for AI013x0x1xDecoder<'_> {
|
||||
if self.information.getSize()
|
||||
!= Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::WEIGHT_SIZE + Self::DATE_SIZE
|
||||
{
|
||||
return Err(crate::Exceptions::notFound);
|
||||
return Err(crate::Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
@@ -53,7 +53,7 @@ impl AbstractExpandedDecoder for AI013x0xDecoder<'_> {
|
||||
if self.information.getSize()
|
||||
!= Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::WEIGHT_SIZE
|
||||
{
|
||||
return Err(crate::Exceptions::notFound);
|
||||
return Err(crate::Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
@@ -52,7 +52,7 @@ impl DecodedNumeric {
|
||||
if
|
||||
/*firstDigit < 0 ||*/
|
||||
firstDigit > 10 || /*secondDigit < 0 ||*/ secondDigit > 10 {
|
||||
return Err(Exceptions::format);
|
||||
return Err(Exceptions::FORMAT);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
|
||||
@@ -146,7 +146,7 @@ pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String> {
|
||||
// Processing 2-digit AIs
|
||||
|
||||
if rawInformation.chars().count() < 2 {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let lookup: String = rawInformation.chars().take(2).collect();
|
||||
@@ -159,7 +159,7 @@ pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String> {
|
||||
}
|
||||
|
||||
if rawInformation.chars().count() < 3 {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let firstThreeDigits: String = rawInformation.chars().take(3).collect();
|
||||
@@ -172,7 +172,7 @@ pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String> {
|
||||
}
|
||||
|
||||
if rawInformation.chars().count() < 4 {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let threeDigitPlusDigitDataLength = THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH.get(&firstThreeDigits);
|
||||
@@ -192,18 +192,18 @@ pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String> {
|
||||
return processFixedAI(4, ffdl.length, rawInformation);
|
||||
}
|
||||
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
fn processFixedAI(aiSize: usize, fieldSize: usize, rawInformation: &str) -> Result<String> {
|
||||
if rawInformation.chars().count() < aiSize {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let ai: String = rawInformation.chars().take(aiSize).collect();
|
||||
|
||||
if rawInformation.chars().count() < aiSize + fieldSize {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let field: String = rawInformation
|
||||
|
||||
@@ -198,7 +198,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if let Some(r) = result.getDecodedInformation() {
|
||||
Ok(r.clone())
|
||||
} else {
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,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::parse)?,
|
||||
char::from_u32('0' as u32 + fiveBitValue - 5).ok_or(Exceptions::PARSE)?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -353,14 +353,14 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if (64..90).contains(&sevenBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 7,
|
||||
char::from_u32(sevenBitValue + 1).ok_or(Exceptions::parse)?,
|
||||
char::from_u32(sevenBitValue + 1).ok_or(Exceptions::PARSE)?,
|
||||
));
|
||||
}
|
||||
|
||||
if (90..116).contains(&sevenBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 7,
|
||||
char::from_u32(sevenBitValue + 7).ok_or(Exceptions::parse)?,
|
||||
char::from_u32(sevenBitValue + 7).ok_or(Exceptions::PARSE)?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
250 => '?',
|
||||
251 => '_',
|
||||
252 => ' ',
|
||||
_ => return Err(Exceptions::format),
|
||||
_ => return Err(Exceptions::FORMAT),
|
||||
};
|
||||
|
||||
Ok(DecodedChar::new(pos + 8, c))
|
||||
@@ -422,7 +422,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::parse)?,
|
||||
char::from_u32('0' as u32 + fiveBitValue - 5).ok_or(Exceptions::PARSE)?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
if (32..58).contains(&sixBitValue) {
|
||||
return Ok(DecodedChar::new(
|
||||
pos + 6,
|
||||
char::from_u32(sixBitValue + 33).ok_or(Exceptions::parse)?,
|
||||
char::from_u32(sixBitValue + 33).ok_or(Exceptions::PARSE)?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
61 => '.',
|
||||
62 => '/',
|
||||
_ => {
|
||||
return Err(Exceptions::illegalStateWith(format!(
|
||||
return Err(Exceptions::illegal_state_with(format!(
|
||||
"Decoding invalid alphanumeric value: {sixBitValue}"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ impl Reader for RSSExpandedReader {
|
||||
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ impl RSSExpandedReader {
|
||||
if let Ok(to_add) = to_add_res {
|
||||
self.pairs.push(to_add);
|
||||
} else if self.pairs.is_empty() {
|
||||
return Err(to_add_res.err().unwrap_or(Exceptions::illegalState));
|
||||
return Err(to_add_res.err().unwrap_or(Exceptions::ILLEGAL_STATE));
|
||||
} else {
|
||||
// exit this loop when retrieveNextPair() fails and throws
|
||||
done = true;
|
||||
@@ -326,7 +326,7 @@ impl RSSExpandedReader {
|
||||
// }
|
||||
}
|
||||
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
fn checkRows(&mut self, reverse: bool) -> Option<Vec<ExpandedPair>> {
|
||||
@@ -370,7 +370,7 @@ impl RSSExpandedReader {
|
||||
) -> Result<Vec<ExpandedPair>> {
|
||||
for i in currentRow..self.rows.len() {
|
||||
// for (int i = currentRow; i < rows.size(); i++) {
|
||||
let row = self.rows.get(i).ok_or(Exceptions::indexOutOfBounds)?;
|
||||
let row = self.rows.get(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
|
||||
self.pairs.clear();
|
||||
for collectedRow in &collectedRows.clone() {
|
||||
// for (ExpandedRow collectedRow : collectedRows) {
|
||||
@@ -398,7 +398,7 @@ impl RSSExpandedReader {
|
||||
}
|
||||
}
|
||||
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
/// Whether the pairs form a valid find pattern sequence,
|
||||
@@ -529,24 +529,24 @@ impl RSSExpandedReader {
|
||||
// Not private for unit testing
|
||||
pub(crate) fn constructRXingResult(pairs: &[ExpandedPair]) -> Result<RXingResult> {
|
||||
let binary = bit_array_builder::buildBitArray(&pairs.to_vec())
|
||||
.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
.ok_or(Exceptions::ILLEGAL_STATE)?;
|
||||
|
||||
let mut decoder = abstract_expanded_decoder::createDecoder(&binary)?;
|
||||
let resultingString = decoder.parseInformation()?;
|
||||
|
||||
let firstPoints = pairs
|
||||
.get(0)
|
||||
.ok_or(Exceptions::indexOutOfBounds)?
|
||||
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
|
||||
.getFinderPattern()
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::illegalState)?
|
||||
.ok_or(Exceptions::ILLEGAL_STATE)?
|
||||
.getPoints();
|
||||
let lastPoints = pairs
|
||||
.last()
|
||||
.ok_or(Exceptions::indexOutOfBounds)?
|
||||
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
|
||||
.getFinderPattern()
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::illegalState)?
|
||||
.ok_or(Exceptions::ILLEGAL_STATE)?
|
||||
.getPoints();
|
||||
|
||||
let mut result = RXingResult::new(
|
||||
@@ -645,7 +645,7 @@ impl RSSExpandedReader {
|
||||
|
||||
let leftChar = self.decodeDataCharacter(
|
||||
row,
|
||||
pattern.as_ref().ok_or(Exceptions::notFound)?,
|
||||
pattern.as_ref().ok_or(Exceptions::NOT_FOUND)?,
|
||||
isOddPattern,
|
||||
true,
|
||||
)?;
|
||||
@@ -653,16 +653,16 @@ impl RSSExpandedReader {
|
||||
if !previousPairs.is_empty()
|
||||
&& previousPairs
|
||||
.last()
|
||||
.ok_or(Exceptions::notFound)?
|
||||
.ok_or(Exceptions::NOT_FOUND)?
|
||||
.mustBeLast()
|
||||
{
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let rightChar = self
|
||||
.decodeDataCharacter(
|
||||
row,
|
||||
pattern.as_ref().ok_or(Exceptions::notFound)?,
|
||||
pattern.as_ref().ok_or(Exceptions::NOT_FOUND)?,
|
||||
isOddPattern,
|
||||
false,
|
||||
)
|
||||
@@ -692,11 +692,11 @@ impl RSSExpandedReader {
|
||||
} else if previousPairs.is_empty() {
|
||||
rowOffset = 0;
|
||||
} else {
|
||||
let lastPair = previousPairs.last().ok_or(Exceptions::indexOutOfBounds)?;
|
||||
let lastPair = previousPairs.last().ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
|
||||
rowOffset = lastPair
|
||||
.getFinderPattern()
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::illegalState)?
|
||||
.ok_or(Exceptions::ILLEGAL_STATE)?
|
||||
.getStartEnd()[1] as i32;
|
||||
}
|
||||
let mut searchingEvenPair = previousPairs.len() % 2 != 0;
|
||||
@@ -748,7 +748,7 @@ impl RSSExpandedReader {
|
||||
isWhite = !isWhite;
|
||||
}
|
||||
}
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
fn reverseCounters(counters: &mut [u32]) {
|
||||
@@ -845,7 +845,7 @@ impl RSSExpandedReader {
|
||||
let expectedElementWidth: f32 =
|
||||
(pattern.getStartEnd()[1] - pattern.getStartEnd()[0]) as f32 / 15.0;
|
||||
if (elementWidth - expectedElementWidth).abs() / expectedElementWidth > 0.3 {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
for (i, counter) in counters.iter().enumerate() {
|
||||
@@ -854,12 +854,12 @@ impl RSSExpandedReader {
|
||||
let mut count = (value + 0.5) as i32; // Round
|
||||
if count < 1 {
|
||||
if value < 0.3 {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
count = 1;
|
||||
} else if count > 8 {
|
||||
if value > 8.7 {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
count = 8;
|
||||
}
|
||||
@@ -899,7 +899,7 @@ impl RSSExpandedReader {
|
||||
let checksumPortion = oddChecksumPortion + evenChecksumPortion;
|
||||
|
||||
if (oddSum & 0x01) != 0 || !(4..=13).contains(&oddSum) {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
|
||||
let group = ((13 - oddSum) / 2) as usize;
|
||||
@@ -947,12 +947,12 @@ impl RSSExpandedReader {
|
||||
1 => {
|
||||
if oddParityBad {
|
||||
if evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
decrementOdd = true;
|
||||
} else {
|
||||
if !evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
decrementEven = true;
|
||||
}
|
||||
@@ -960,12 +960,12 @@ impl RSSExpandedReader {
|
||||
-1 => {
|
||||
if oddParityBad {
|
||||
if evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
incrementOdd = true;
|
||||
} else {
|
||||
if !evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
incrementEven = true;
|
||||
}
|
||||
@@ -973,7 +973,7 @@ impl RSSExpandedReader {
|
||||
0 => {
|
||||
if oddParityBad {
|
||||
if !evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
// Both bad
|
||||
if oddSum < evenSum {
|
||||
@@ -984,16 +984,16 @@ impl RSSExpandedReader {
|
||||
incrementEven = true;
|
||||
}
|
||||
} else if evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
_ => return Err(Exceptions::notFound),
|
||||
_ => return Err(Exceptions::NOT_FOUND),
|
||||
}
|
||||
|
||||
if incrementOdd {
|
||||
if decrementOdd {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
Self::increment(&mut self.oddCounts, &self.oddRoundingErrors);
|
||||
}
|
||||
@@ -1002,7 +1002,7 @@ impl RSSExpandedReader {
|
||||
}
|
||||
if incrementEven {
|
||||
if decrementEven {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
Self::increment(&mut self.evenCounts, &self.oddRoundingErrors);
|
||||
}
|
||||
|
||||
@@ -64,12 +64,12 @@ impl OneDReader for RSS14Reader {
|
||||
if right.getCount() > 1 && self.checkChecksum(left, right) {
|
||||
return self
|
||||
.constructRXingResult(left, right)
|
||||
.ok_or(Exceptions::illegalState);
|
||||
.ok_or(Exceptions::ILLEGAL_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
}
|
||||
impl Reader for RSS14Reader {
|
||||
@@ -123,7 +123,7 @@ impl Reader for RSS14Reader {
|
||||
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,7 +340,7 @@ impl RSS14Reader {
|
||||
|
||||
if outsideChar {
|
||||
if (oddSum & 0x01) != 0 || !(4..=12).contains(&oddSum) {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
let group = ((12 - oddSum) / 2) as usize;
|
||||
let oddWidest = Self::OUTSIDE_ODD_WIDEST[group];
|
||||
@@ -355,7 +355,7 @@ impl RSS14Reader {
|
||||
))
|
||||
} else {
|
||||
if (evenSum & 0x01) != 0 || !(4..=10).contains(&evenSum) {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
let group = ((10 - evenSum) / 2) as usize;
|
||||
let oddWidest = Self::INSIDE_ODD_WIDEST[group];
|
||||
@@ -414,7 +414,7 @@ impl RSS14Reader {
|
||||
isWhite = !isWhite;
|
||||
}
|
||||
}
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
fn parseFoundFinderPattern(
|
||||
@@ -511,12 +511,12 @@ impl RSS14Reader {
|
||||
1 => {
|
||||
if oddParityBad {
|
||||
if evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
decrementOdd = true;
|
||||
} else {
|
||||
if !evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
decrementEven = true;
|
||||
}
|
||||
@@ -524,12 +524,12 @@ impl RSS14Reader {
|
||||
-1 => {
|
||||
if oddParityBad {
|
||||
if evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
incrementOdd = true;
|
||||
} else {
|
||||
if !evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
incrementEven = true;
|
||||
}
|
||||
@@ -537,7 +537,7 @@ impl RSS14Reader {
|
||||
0 => {
|
||||
if oddParityBad {
|
||||
if !evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
// Both bad
|
||||
if oddSum < evenSum {
|
||||
@@ -548,15 +548,15 @@ impl RSS14Reader {
|
||||
incrementEven = true;
|
||||
}
|
||||
} else if evenParityBad {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
}
|
||||
_ => return Err(Exceptions::notFound),
|
||||
_ => return Err(Exceptions::NOT_FOUND),
|
||||
}
|
||||
|
||||
if incrementOdd {
|
||||
if decrementOdd {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
Self::increment(&mut self.oddCounts, &self.oddRoundingErrors);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ impl RSS14Reader {
|
||||
}
|
||||
if incrementEven {
|
||||
if decrementEven {
|
||||
return Err(Exceptions::notFound);
|
||||
return Err(Exceptions::NOT_FOUND);
|
||||
}
|
||||
Self::increment(&mut self.evenCounts, &self.evenRoundingErrors);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user