From 5daf433b0654efe0fcd5bfae1a748c4f4d28804e Mon Sep 17 00:00:00 2001 From: Chris Biscardi Date: Fri, 9 Aug 2024 14:10:45 -0700 Subject: [PATCH] feat(Blenvy:Bevy): improve error message for ReflectComponent data in copy_components(#222) --- crates/blenvy/src/blueprints/copy_components.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/blenvy/src/blueprints/copy_components.rs b/crates/blenvy/src/blueprints/copy_components.rs index b2a12b5..7e39126 100644 --- a/crates/blenvy/src/blueprints/copy_components.rs +++ b/crates/blenvy/src/blueprints/copy_components.rs @@ -69,10 +69,15 @@ impl CopyComponents { } }) .map(|type_id| { - return ( - type_id.data::().unwrap().clone(), - type_id.type_info().type_id(), // we need the original type_id down the line - ); + match type_id.data::() { + Some(data) => ( + data.clone(), + type_id.type_info().type_id(), // we need the original type_id down the line + ), + None => { + panic!("type {:?}'s ReflectComponent data was not found in the type registry, this could be because the type is missing a #[reflect(Component)]", type_id.type_info().type_path()); + } + } }) .collect::>() };