diff --git a/crates/fj-kernel/src/objects/mod.rs b/crates/fj-kernel/src/objects/mod.rs index dba16edd5..bdba01e72 100644 --- a/crates/fj-kernel/src/objects/mod.rs +++ b/crates/fj-kernel/src/objects/mod.rs @@ -103,8 +103,8 @@ use crate::{ path::GlobalPath, storage::{Handle, Store}, validate::{ - HalfEdgeValidationError, SurfaceVertexValidationError, Validate2, - VertexValidationError, + CycleValidationError, HalfEdgeValidationError, + SurfaceVertexValidationError, Validate2, VertexValidationError, }, }; @@ -187,7 +187,10 @@ pub struct Cycles { impl Cycles { /// Insert a [`Cycle`] into the store - pub fn insert(&self, cycle: Cycle) -> Result, Infallible> { + pub fn insert( + &self, + cycle: Cycle, + ) -> Result, CycleValidationError> { cycle.validate()?; Ok(self.store.insert(cycle)) } diff --git a/crates/fj-kernel/src/validate/cycle.rs b/crates/fj-kernel/src/validate/cycle.rs index 57eb8b348..83ce06b68 100644 --- a/crates/fj-kernel/src/validate/cycle.rs +++ b/crates/fj-kernel/src/validate/cycle.rs @@ -1,11 +1,9 @@ -use std::convert::Infallible; - use crate::objects::Cycle; use super::{Validate2, ValidationConfig}; impl Validate2 for Cycle { - type Error = Infallible; + type Error = CycleValidationError; fn validate_with_config( &self, @@ -14,3 +12,7 @@ impl Validate2 for Cycle { Ok(()) } } + +/// [`Cycle`] validation error +#[derive(Debug, thiserror::Error)] +pub enum CycleValidationError {} diff --git a/crates/fj-kernel/src/validate/mod.rs b/crates/fj-kernel/src/validate/mod.rs index 32abea1c3..5d73d839f 100644 --- a/crates/fj-kernel/src/validate/mod.rs +++ b/crates/fj-kernel/src/validate/mod.rs @@ -26,6 +26,7 @@ mod uniqueness; mod vertex; pub use self::{ + cycle::CycleValidationError, edge::HalfEdgeValidationError, uniqueness::UniquenessIssues, vertex::{SurfaceVertexValidationError, VertexValidationError}, @@ -177,6 +178,10 @@ pub enum ValidationError { #[error("Uniqueness validation failed")] Uniqueness(#[from] UniquenessIssues), + /// `Cycle` validation error + #[error(transparent)] + Cycle(#[from] CycleValidationError), + /// `HalfEdge` validation error #[error(transparent)] HalfEdge(#[from] HalfEdgeValidationError),