mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
Use thiserror for error handling with less boilerplate
This commit is contained in:
@@ -102,14 +102,14 @@ impl Version {
|
||||
*/
|
||||
pub fn getProvisionalVersionForDimension(dimension: u32) -> Result<&'static Version> {
|
||||
if dimension % 4 != 1 {
|
||||
return Err(Exceptions::formatWith("dimension incorrect"));
|
||||
return Err(Exceptions::format_with("dimension incorrect"));
|
||||
}
|
||||
Self::getVersionForNumber((dimension - 17) / 4)
|
||||
}
|
||||
|
||||
pub fn getVersionForNumber(versionNumber: u32) -> Result<&'static Version> {
|
||||
if !(1..=40).contains(&versionNumber) {
|
||||
return Err(Exceptions::illegalArgumentWith("version out of spec"));
|
||||
return Err(Exceptions::illegal_argument_with("version out of spec"));
|
||||
}
|
||||
Ok(&VERSIONS[versionNumber as usize - 1])
|
||||
}
|
||||
@@ -137,7 +137,7 @@ impl Version {
|
||||
return Self::getVersionForNumber(bestVersion);
|
||||
}
|
||||
// If we didn't find a close enough match, fail
|
||||
Err(Exceptions::notFound)
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user