diff --git a/crates/fj-kernel/src/objects/mod.rs b/crates/fj-kernel/src/objects/mod.rs index 07a37bd53..c35a28972 100644 --- a/crates/fj-kernel/src/objects/mod.rs +++ b/crates/fj-kernel/src/objects/mod.rs @@ -103,7 +103,7 @@ use crate::{ path::GlobalPath, storage::{Handle, Store}, validate::{ - CycleValidationError, HalfEdgeValidationError, + CycleValidationError, FaceValidationError, HalfEdgeValidationError, SurfaceVertexValidationError, Validate2, VertexValidationError, }, }; @@ -204,7 +204,10 @@ pub struct Faces { impl Faces { /// Insert a [`Face`] into the store - pub fn insert(&self, face: Face) -> Result, Infallible> { + pub fn insert( + &self, + face: Face, + ) -> Result, FaceValidationError> { face.validate()?; Ok(self.store.insert(face)) } diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 934695e19..a740f4e18 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -1,11 +1,9 @@ -use std::convert::Infallible; - use crate::objects::Face; use super::{Validate2, ValidationConfig}; impl Validate2 for Face { - type Error = Infallible; + type Error = FaceValidationError; fn validate_with_config( &self, @@ -14,3 +12,7 @@ impl Validate2 for Face { Ok(()) } } + +/// [`Face`] validation error +#[derive(Debug, thiserror::Error)] +pub enum FaceValidationError {} diff --git a/crates/fj-kernel/src/validate/mod.rs b/crates/fj-kernel/src/validate/mod.rs index 5d73d839f..f1a290243 100644 --- a/crates/fj-kernel/src/validate/mod.rs +++ b/crates/fj-kernel/src/validate/mod.rs @@ -28,6 +28,7 @@ mod vertex; pub use self::{ cycle::CycleValidationError, edge::HalfEdgeValidationError, + face::FaceValidationError, uniqueness::UniquenessIssues, vertex::{SurfaceVertexValidationError, VertexValidationError}, }; @@ -182,6 +183,10 @@ pub enum ValidationError { #[error(transparent)] Cycle(#[from] CycleValidationError), + /// `Face` validation error + #[error(transparent)] + Face(#[from] FaceValidationError), + /// `HalfEdge` validation error #[error(transparent)] HalfEdge(#[from] HalfEdgeValidationError),