mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
refactor to use exception helper factories
This commit is contained in:
@@ -140,7 +140,7 @@ impl OneDReader for ITFReader {
|
||||
lengthOK = true;
|
||||
}
|
||||
if !lengthOK {
|
||||
return Err(Exceptions::FormatException(None));
|
||||
return Err(Exceptions::formatEmpty());
|
||||
}
|
||||
|
||||
let mut resultObject = RXingResult::new(
|
||||
@@ -195,13 +195,11 @@ impl ITFReader {
|
||||
}
|
||||
|
||||
let mut bestMatch = self.decodeDigit(&counterBlack)?;
|
||||
resultString.push(
|
||||
char::from_u32('0' as u32 + bestMatch).ok_or(Exceptions::ParseException(None))?,
|
||||
);
|
||||
resultString
|
||||
.push(char::from_u32('0' as u32 + bestMatch).ok_or(Exceptions::parseEmpty())?);
|
||||
bestMatch = self.decodeDigit(&counterWhite)?;
|
||||
resultString.push(
|
||||
char::from_u32('0' as u32 + bestMatch).ok_or(Exceptions::ParseException(None))?,
|
||||
);
|
||||
resultString
|
||||
.push(char::from_u32('0' as u32 + bestMatch).ok_or(Exceptions::parseEmpty())?);
|
||||
|
||||
payloadStart += counterDigitPair.iter().sum::<u32>() as usize;
|
||||
}
|
||||
@@ -262,7 +260,7 @@ impl ITFReader {
|
||||
|
||||
if quietCount != 0 {
|
||||
// Unable to find the necessary number of quiet zone pixels.
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFoundEmpty())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
@@ -279,7 +277,7 @@ impl ITFReader {
|
||||
let width = row.getSize();
|
||||
let endStart = row.getNextSet(0);
|
||||
if endStart == width {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFoundEmpty());
|
||||
}
|
||||
|
||||
Ok(endStart)
|
||||
@@ -374,7 +372,7 @@ impl ITFReader {
|
||||
isWhite = !isWhite;
|
||||
}
|
||||
}
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFoundEmpty())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,7 +401,7 @@ impl ITFReader {
|
||||
if bestMatch >= 0 {
|
||||
Ok(bestMatch as u32 % 10)
|
||||
} else {
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFoundEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user