mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
Use thiserror for error handling with less boilerplate
This commit is contained in:
@@ -218,7 +218,7 @@ fn addEdge(edges: &mut [Vec<Option<Rc<Edge>>>], edge: Rc<Edge>) -> Result<()> {
|
||||
if edges[vertexIndex][edge.getEndMode()?.ordinal()].is_none()
|
||||
|| edges[vertexIndex][edge.getEndMode()?.ordinal()]
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::illegalState)?
|
||||
.ok_or(Exceptions::ILLEGAL_STATE)?
|
||||
.cachedTotalSize
|
||||
> edge.cachedTotalSize
|
||||
{
|
||||
@@ -635,7 +635,7 @@ fn encodeMinimally(input: Rc<Input>) -> Result<RXingResult> {
|
||||
}
|
||||
|
||||
if minimalJ < 0 {
|
||||
return Err(Exceptions::illegalStateWith(format!(
|
||||
return Err(Exceptions::illegal_state_with(format!(
|
||||
"Internal error: failed to encode \"{input}\""
|
||||
)));
|
||||
}
|
||||
@@ -669,7 +669,7 @@ impl Edge {
|
||||
previous: Option<Rc<Edge>>,
|
||||
) -> Result<Self> {
|
||||
if fromPosition + characterLength > input.length() as u32 {
|
||||
return Err(Exceptions::format);
|
||||
return Err(Exceptions::FORMAT);
|
||||
}
|
||||
|
||||
let mut size = if let Some(previous) = previous.clone() {
|
||||
@@ -1276,7 +1276,7 @@ impl RXingResult {
|
||||
let solution = if let Some(edge) = solution {
|
||||
edge
|
||||
} else {
|
||||
return Err(Exceptions::illegalArgument);
|
||||
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||
};
|
||||
let input = solution.input.clone();
|
||||
let mut size = 0;
|
||||
|
||||
Reference in New Issue
Block a user