mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
refactor to use exception helper factories
This commit is contained in:
@@ -60,21 +60,21 @@ impl Writer for DataMatrixWriter {
|
||||
hints: &crate::EncodingHintDictionary,
|
||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||
if contents.is_empty() {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Found empty contents".to_owned(),
|
||||
)));
|
||||
));
|
||||
}
|
||||
|
||||
if format != &BarcodeFormat::DATA_MATRIX {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
return Err(Exceptions::illegalArgument(format!(
|
||||
"Can only encode DATA_MATRIX, but got {format:?}"
|
||||
))));
|
||||
)));
|
||||
}
|
||||
|
||||
if width < 0 || height < 0 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
return Err(Exceptions::illegalArgument(format!(
|
||||
"Requested dimensions can't be negative: {width}x{height}"
|
||||
))));
|
||||
)));
|
||||
}
|
||||
|
||||
// Try to get force shape & min / max size
|
||||
@@ -123,7 +123,7 @@ impl Writer for DataMatrixWriter {
|
||||
if hasEncodingHint {
|
||||
let Some(EncodeHintValue::CharacterSet(char_set_name)) =
|
||||
hints.get(&EncodeHintType::CHARACTER_SET) else {
|
||||
return Err(Exceptions::IllegalArgumentException(Some("charset does not exist".to_owned())))
|
||||
return Err(Exceptions::illegalArgument("charset does not exist".to_owned()))
|
||||
};
|
||||
charset = encoding::label::encoding_from_whatwg_label(char_set_name);
|
||||
// charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
|
||||
@@ -157,7 +157,7 @@ impl Writer for DataMatrixWriter {
|
||||
|
||||
let symbol_lookup = SymbolInfoLookup::new();
|
||||
let Some(symbolInfo) = symbol_lookup.lookup_with_codewords_shape_size_fail(encoded.chars().count() as u32, *shape, &minSize, &maxSize, true)? else {
|
||||
return Err(Exceptions::NotFoundException(Some("symbol info is bad".to_owned())))
|
||||
return Err(Exceptions::notFound("symbol info is bad".to_owned()))
|
||||
};
|
||||
|
||||
//2. step: ECC generation
|
||||
|
||||
Reference in New Issue
Block a user