Use thiserror for error handling with less boilerplate

This commit is contained in:
Steve Cook
2023-02-20 09:41:28 -05:00
parent 01e4f4a126
commit f8b29f37db
135 changed files with 868 additions and 905 deletions

View File

@@ -125,7 +125,7 @@ pub trait OneDReader: Reader {
}
}
Err(Exceptions::notFound)
Err(Exceptions::NOT_FOUND)
}
/**
@@ -212,7 +212,7 @@ pub fn recordPattern(row: &BitArray, start: usize, counters: &mut [u32]) -> Resu
let end = row.getSize();
if start >= end {
return Err(Exceptions::notFound);
return Err(Exceptions::NOT_FOUND);
}
let mut isWhite = !row.get(start);
@@ -235,7 +235,7 @@ pub fn recordPattern(row: &BitArray, start: usize, counters: &mut [u32]) -> Resu
// If we read fully the last section of pixels and filled up our counters -- or filled
// the last counter but ran off the side of the image, OK. Otherwise, a problem.
if !(counterPosition == numCounters || (counterPosition == numCounters - 1 && i == end)) {
return Err(Exceptions::notFound);
return Err(Exceptions::NOT_FOUND);
}
Ok(())
}
@@ -253,7 +253,7 @@ pub fn recordPatternInReverse(row: &BitArray, start: usize, counters: &mut [u32]
}
}
if numTransitionsLeft >= 0 {
return Err(Exceptions::notFound);
return Err(Exceptions::NOT_FOUND);
}
recordPattern(row, start + 1, counters)?;