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

@@ -56,7 +56,7 @@ impl<T: Reader> MultipleBarcodeReader for GenericMultipleBarcodeReader<T> {
let mut results = Vec::new();
self.doDecodeMultiple(image, hints, &mut results, 0, 0, 0);
if results.is_empty() {
return Err(Exceptions::notFound);
return Err(Exceptions::NOT_FOUND);
}
Ok(results)
}

View File

@@ -50,7 +50,7 @@ impl<'a> MultiDetector<'_> {
let infos = finder.findMulti(hints)?;
if infos.is_empty() {
return Err(Exceptions::notFound);
return Err(Exceptions::NOT_FOUND);
}
let mut result = Vec::new();

View File

@@ -92,7 +92,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
if size < 3 {
// Couldn't find enough finder patterns
return Err(Exceptions::notFoundWith(
return Err(Exceptions::not_found_with(
"Couldn't find enough finder patterns",
));
}
@@ -212,7 +212,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
if !results.is_empty() {
Ok(results)
} else {
Err(Exceptions::notFound)
Err(Exceptions::NOT_FOUND)
}
}

View File

@@ -111,7 +111,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
// ignore and continue
continue;
} else {
return Err(output.err().unwrap_or(Exceptions::notFound));
return Err(output.err().unwrap_or(Exceptions::NOT_FOUND));
}
}