diff --git a/fj-kernel/src/algorithms/approximation.rs b/fj-kernel/src/algorithms/approximation.rs index 624f47d9a..29a467bf3 100644 --- a/fj-kernel/src/algorithms/approximation.rs +++ b/fj-kernel/src/algorithms/approximation.rs @@ -184,11 +184,13 @@ impl Tolerance { /// Construct a `Tolerance` from a [`Scalar`] /// /// Returns an error, if the passed scalar is not larger than zero. - pub fn from_scalar(scalar: impl Into) -> Result { + pub fn from_scalar( + scalar: impl Into, + ) -> Result { let scalar = scalar.into(); if scalar <= Scalar::ZERO { - return Err(scalar); + return Err(InvalidTolerance(scalar)); } Ok(Self(scalar)) @@ -209,6 +211,10 @@ where } } +#[derive(Debug, thiserror::Error)] +#[error("Invalid tolerance ({0}); must be above zero")] +pub struct InvalidTolerance(Scalar); + #[cfg(test)] mod tests { use fj_math::{Point, Scalar};