Skip to content

Commit

Permalink
Don't panic on validation errors in handle_model
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jun 26, 2023
1 parent 7f39c59 commit 179af82
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/fj/src/handle_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use fj_core::{
triangulate::Triangulate,
},
services::Services,
validate::ValidationErrors,
};
use fj_interop::model::Model;
use fj_math::{Aabb, Point, Scalar};
Expand All @@ -31,10 +32,7 @@ where
{
let args = Args::parse();

// Dropping `Services` will cause a panic, if there are any unhandled
// validation errors. It would be better to return an error, but this will
// do for now.
drop(services);
services.drop_and_validate()?;

let aabb = model.aabb().unwrap_or(Aabb {
min: Point::origin(),
Expand Down Expand Up @@ -91,4 +89,8 @@ pub enum Error {
/// Invalid tolerance
#[error(transparent)]
Tolerance(#[from] InvalidTolerance),

/// Unhandled validation errors
#[error(transparent)]
Validation(#[from] ValidationErrors),
}

0 comments on commit 179af82

Please sign in to comment.