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

@@ -87,7 +87,7 @@ impl UPCEANExtension5Support {
)?;
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;
@@ -105,15 +105,14 @@ impl UPCEANExtension5Support {
}
if resultString.chars().count() != 5 {
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
let checkDigit = Self::determineCheckDigit(lgPatternFound)?;
if Self::extensionChecksum(resultString)
.ok_or(Exceptions::IllegalArgumentException(None))?
if Self::extensionChecksum(resultString).ok_or(Exceptions::illegalArgumentEmpty())?
!= checkDigit as u32
{
return Err(Exceptions::NotFoundException(None));
return Err(Exceptions::notFoundEmpty());
}
Ok(rowOffset as u32)
@@ -148,7 +147,7 @@ impl UPCEANExtension5Support {
return Ok(d);
}
}
Err(Exceptions::NotFoundException(None))
Err(Exceptions::notFoundEmpty())
}
/**