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:
@@ -168,7 +168,7 @@ impl BitArray {
|
||||
pub fn setRange(&mut self, start: usize, end: usize) -> Result<(), Exceptions> {
|
||||
let mut end = end;
|
||||
if end < start || end > self.size {
|
||||
return Err(Exceptions::IllegalArgumentException(None));
|
||||
return Err(Exceptions::illegalArgumentEmpty());
|
||||
}
|
||||
if end == start {
|
||||
return Ok(());
|
||||
@@ -211,7 +211,7 @@ impl BitArray {
|
||||
pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool, Exceptions> {
|
||||
let mut end = end;
|
||||
if end < start || end > self.size {
|
||||
return Err(Exceptions::IllegalArgumentException(None));
|
||||
return Err(Exceptions::illegalArgumentEmpty());
|
||||
}
|
||||
if end == start {
|
||||
return Ok(true); // empty range matches
|
||||
@@ -253,9 +253,9 @@ impl BitArray {
|
||||
*/
|
||||
pub fn appendBits(&mut self, value: u32, num_bits: usize) -> Result<(), Exceptions> {
|
||||
if num_bits > 32 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"num bits must be between 0 and 32".to_owned(),
|
||||
)));
|
||||
));
|
||||
}
|
||||
|
||||
if num_bits == 0 {
|
||||
@@ -286,9 +286,7 @@ impl BitArray {
|
||||
|
||||
pub fn xor(&mut self, other: &BitArray) -> Result<(), Exceptions> {
|
||||
if self.size != other.size {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(
|
||||
"Sizes don't match".to_owned(),
|
||||
)));
|
||||
return Err(Exceptions::illegalArgument("Sizes don't match".to_owned()));
|
||||
}
|
||||
for i in 0..self.bits.len() {
|
||||
//for (int i = 0; i < bits.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user