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:
@@ -31,12 +31,12 @@ impl Encoder for ASCIIEncoder {
|
||||
.getMessage()
|
||||
.chars()
|
||||
.nth(context.pos as usize)
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
|
||||
context
|
||||
.getMessage()
|
||||
.chars()
|
||||
.nth(context.pos as usize + 1)
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
|
||||
)? as u8);
|
||||
context.pos += 2;
|
||||
} else {
|
||||
@@ -73,9 +73,7 @@ impl Encoder for ASCIIEncoder {
|
||||
}
|
||||
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||
"Illegal mode: {newMode}"
|
||||
))));
|
||||
return Err(Exceptions::illegalState(format!("Illegal mode: {newMode}")));
|
||||
}
|
||||
}
|
||||
} else if high_level_encoder::isExtendedASCII(c) {
|
||||
@@ -104,9 +102,9 @@ impl ASCIIEncoder {
|
||||
let num = (digit1 as u8 - 48) * 10 + (digit2 as u8 - 48);
|
||||
Ok((num + 130) as char)
|
||||
} else {
|
||||
Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
Err(Exceptions::illegalArgument(format!(
|
||||
"not digits: {digit1}{digit2}"
|
||||
))))
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user