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

@@ -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())
}
}
}