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

@@ -101,18 +101,16 @@ impl Version {
dimension: u32,
) -> Result<&'static Version, Exceptions> {
if dimension % 4 != 1 {
return Err(Exceptions::FormatException(Some(
"dimension incorrect".to_owned(),
)));
return Err(Exceptions::format("dimension incorrect".to_owned()));
}
Self::getVersionForNumber((dimension - 17) / 4)
}
pub fn getVersionForNumber(versionNumber: u32) -> Result<&'static Version, Exceptions> {
if !(1..=40).contains(&versionNumber) {
return Err(Exceptions::IllegalArgumentException(Some(
return Err(Exceptions::illegalArgument(
"version out of spec".to_owned(),
)));
));
}
Ok(&VERSIONS[versionNumber as usize - 1])
}
@@ -140,7 +138,7 @@ impl Version {
return Self::getVersionForNumber(bestVersion);
}
// If we didn't find a close enough match, fail
Err(Exceptions::NotFoundException(None))
Err(Exceptions::notFoundEmpty())
}
/**