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:
@@ -44,7 +44,7 @@ impl BoundingBox {
|
||||
let leftUnspecified = topLeft.is_none() || bottomLeft.is_none();
|
||||
let rightUnspecified = topRight.is_none() || bottomRight.is_none();
|
||||
if leftUnspecified && rightUnspecified {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
return Err(Exceptions::notFoundEmpty());
|
||||
}
|
||||
|
||||
let newTopLeft;
|
||||
@@ -53,21 +53,21 @@ impl BoundingBox {
|
||||
let newBottomRight;
|
||||
|
||||
if leftUnspecified {
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = topRight.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newTopLeft = RXingResultPoint::new(0.0, newTopRight.getY());
|
||||
newBottomLeft = RXingResultPoint::new(0.0, newBottomRight.getY());
|
||||
} else if rightUnspecified {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopLeft = topLeft.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newTopRight = RXingResultPoint::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newBottomRight =
|
||||
RXingResultPoint::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
} else {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopLeft = topLeft.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newTopRight = topRight.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
}
|
||||
|
||||
Ok(BoundingBox {
|
||||
@@ -104,17 +104,17 @@ impl BoundingBox {
|
||||
if leftBox.is_none() {
|
||||
return Ok(rightBox
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::IllegalStateException(None))?
|
||||
.ok_or(Exceptions::illegalStateEmpty())?
|
||||
.clone());
|
||||
}
|
||||
if rightBox.is_none() {
|
||||
return Ok(leftBox
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::IllegalStateException(None))?
|
||||
.ok_or(Exceptions::illegalStateEmpty())?
|
||||
.clone());
|
||||
}
|
||||
let leftBox = leftBox.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
let rightBox = rightBox.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
let leftBox = leftBox.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
let rightBox = rightBox.ok_or(Exceptions::illegalStateEmpty())?;
|
||||
|
||||
BoundingBox::new(
|
||||
leftBox.image,
|
||||
|
||||
Reference in New Issue
Block a user