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

@@ -124,7 +124,7 @@ impl<'a> Detector<'_> {
|| !self.is_valid(bulls_eye_corners[2])
|| !self.is_valid(bulls_eye_corners[3])
{
return Err(Exceptions::notFoundWith("no valid points"));
return Err(Exceptions::not_found_with("no valid points"));
}
let length = 2 * self.nb_center_layers;
// Get the bits around the bull's eye
@@ -205,7 +205,7 @@ impl<'a> Detector<'_> {
return Ok(shift);
}
}
Err(Exceptions::notFoundWith("rotation failure"))
Err(Exceptions::not_found_with("rotation failure"))
}
/**
@@ -314,7 +314,7 @@ impl<'a> Detector<'_> {
}
if self.nb_center_layers != 5 && self.nb_center_layers != 7 {
return Err(Exceptions::notFound);
return Err(Exceptions::NOT_FOUND);
}
self.compact = self.nb_center_layers == 5;