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:
@@ -65,7 +65,7 @@ impl C40Encoder {
|
||||
context.updateSymbolInfoWithLength(curCodewordCount);
|
||||
let available = context
|
||||
.getSymbolInfo()
|
||||
.ok_or(Exceptions::IllegalStateException(None))?
|
||||
.ok_or(Exceptions::illegalStateEmpty())?
|
||||
.getDataCapacity() as usize
|
||||
- curCodewordCount;
|
||||
|
||||
@@ -140,7 +140,7 @@ impl C40Encoder {
|
||||
context.updateSymbolInfoWithLength(curCodewordCount);
|
||||
let available = context
|
||||
.getSymbolInfo()
|
||||
.ok_or(Exceptions::IllegalStateException(None))?
|
||||
.ok_or(Exceptions::illegalStateEmpty())?
|
||||
.getDataCapacity() as usize
|
||||
- curCodewordCount;
|
||||
let rest = buffer.chars().count() % 3;
|
||||
@@ -182,9 +182,7 @@ impl C40Encoder {
|
||||
context: &mut EncoderContext,
|
||||
buffer: &mut String,
|
||||
) -> Result<(), Exceptions> {
|
||||
context.writeCodewords(
|
||||
&Self::encodeToCodewords(buffer).ok_or(Exceptions::FormatException(None))?,
|
||||
);
|
||||
context.writeCodewords(&Self::encodeToCodewords(buffer).ok_or(Exceptions::formatEmpty())?);
|
||||
buffer.replace_range(0..3, "");
|
||||
// buffer.delete(0, 3);
|
||||
Ok(())
|
||||
@@ -207,7 +205,7 @@ impl C40Encoder {
|
||||
context.updateSymbolInfoWithLength(curCodewordCount);
|
||||
let available = context
|
||||
.getSymbolInfo()
|
||||
.ok_or(Exceptions::IllegalStateException(None))?
|
||||
.ok_or(Exceptions::illegalStateEmpty())?
|
||||
.getDataCapacity() as usize
|
||||
- curCodewordCount;
|
||||
|
||||
@@ -236,9 +234,9 @@ impl C40Encoder {
|
||||
context.writeCodeword(C40_UNLATCH);
|
||||
}
|
||||
} else {
|
||||
return Err(Exceptions::IllegalStateException(Some(
|
||||
return Err(Exceptions::illegalState(
|
||||
"Unexpected case. Please report!".to_owned(),
|
||||
)));
|
||||
));
|
||||
}
|
||||
context.signalEncoderChange(ASCII_ENCODATION);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user