mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-06 19:08:28 +00:00
Consolidate error variants in ValidationError
This commit is contained in:
parent
d612c0dba3
commit
e92123b0a8
@ -36,7 +36,7 @@ macro_rules! validate_references {
|
||||
$(
|
||||
$counter.find_multiples().iter().for_each(|multiple| {
|
||||
let reference_error = ObjectNotExclusivelyOwned::$err { references: multiple.clone() };
|
||||
$errors.push(Into::<$error_ty>::into(reference_error).into());
|
||||
$errors.push(reference_error.into());
|
||||
});
|
||||
)*
|
||||
};
|
||||
|
@ -37,10 +37,6 @@ impl Validate for Sketch {
|
||||
/// [`Sketch`] validation failed
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
pub enum SketchValidationError {
|
||||
/// An object that should be exclusively owned by another, is not
|
||||
#[error(transparent)]
|
||||
ObjectNotExclusivelyOwned(#[from] ObjectNotExclusivelyOwned),
|
||||
|
||||
/// Region within sketch has exterior cycle with clockwise winding
|
||||
#[error(
|
||||
"Exterior cycle within sketch region has clockwise winding\n
|
||||
@ -170,10 +166,8 @@ mod tests {
|
||||
assert_contains_err!(
|
||||
core,
|
||||
invalid_sketch,
|
||||
ValidationError::Sketch(
|
||||
SketchValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Cycle { references: _ }
|
||||
)
|
||||
ValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Cycle { references: _ }
|
||||
)
|
||||
);
|
||||
|
||||
@ -210,10 +204,8 @@ mod tests {
|
||||
assert_contains_err!(
|
||||
core,
|
||||
invalid_sketch,
|
||||
ValidationError::Sketch(
|
||||
SketchValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::HalfEdge { references: _ }
|
||||
)
|
||||
ValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::HalfEdge { references: _ }
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -67,10 +67,6 @@ pub enum SolidValidationError {
|
||||
/// Position of second vertex
|
||||
position_b: Point<3>,
|
||||
},
|
||||
|
||||
/// Object within solid referenced by more than one other object
|
||||
#[error(transparent)]
|
||||
ObjectNotExclusivelyOwned(#[from] ObjectNotExclusivelyOwned),
|
||||
}
|
||||
|
||||
impl SolidValidationError {
|
||||
@ -188,8 +184,7 @@ mod tests {
|
||||
},
|
||||
topology::{Cycle, Face, HalfEdge, Region, Shell, Solid, Surface},
|
||||
validate::{
|
||||
references::ObjectNotExclusivelyOwned, SolidValidationError,
|
||||
Validate, ValidationError,
|
||||
references::ObjectNotExclusivelyOwned, Validate, ValidationError,
|
||||
},
|
||||
Core,
|
||||
};
|
||||
@ -238,10 +233,8 @@ mod tests {
|
||||
assert_contains_err!(
|
||||
core,
|
||||
invalid_solid,
|
||||
ValidationError::Solid(
|
||||
SolidValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Face { references: _ }
|
||||
)
|
||||
ValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Face { references: _ }
|
||||
)
|
||||
);
|
||||
|
||||
@ -286,10 +279,8 @@ mod tests {
|
||||
assert_contains_err!(
|
||||
core,
|
||||
invalid_solid,
|
||||
ValidationError::Solid(
|
||||
SolidValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Region { references: _ }
|
||||
)
|
||||
ValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Region { references: _ }
|
||||
)
|
||||
);
|
||||
|
||||
@ -338,10 +329,8 @@ mod tests {
|
||||
assert_contains_err!(
|
||||
core,
|
||||
invalid_solid,
|
||||
ValidationError::Solid(
|
||||
SolidValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Cycle { references: _ }
|
||||
)
|
||||
ValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::Cycle { references: _ }
|
||||
)
|
||||
);
|
||||
|
||||
@ -382,10 +371,8 @@ mod tests {
|
||||
assert_contains_err!(
|
||||
core,
|
||||
invalid_solid,
|
||||
ValidationError::Solid(
|
||||
SolidValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::HalfEdge { references: _ }
|
||||
)
|
||||
ValidationError::ObjectNotExclusivelyOwned(
|
||||
ObjectNotExclusivelyOwned::HalfEdge { references: _ }
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
use std::{convert::Infallible, fmt};
|
||||
|
||||
use crate::validate::{SketchValidationError, SolidValidationError};
|
||||
use crate::validate::{
|
||||
ObjectNotExclusivelyOwned, SketchValidationError, SolidValidationError,
|
||||
};
|
||||
|
||||
use super::checks::{
|
||||
AdjacentHalfEdgesNotConnected, CoincidentHalfEdgesAreNotSiblings,
|
||||
@ -37,6 +39,10 @@ pub enum ValidationError {
|
||||
#[error(transparent)]
|
||||
InteriorCycleHasInvalidWinding(#[from] InteriorCycleHasInvalidWinding),
|
||||
|
||||
/// An object that should be exclusively owned by another, is not
|
||||
#[error(transparent)]
|
||||
ObjectNotExclusivelyOwned(#[from] ObjectNotExclusivelyOwned),
|
||||
|
||||
/// `Solid` validation error
|
||||
#[error("`Solid` validation error")]
|
||||
Solid(#[from] SolidValidationError),
|
||||
|
Loading…
Reference in New Issue
Block a user