Skip to content

Commit

Permalink
Fix error in DynamicScene (bevyengine#1651)
Browse files Browse the repository at this point in the history
The wrong error was returned when using an unregistered type in a scene, leading to a confusing error message.
  • Loading branch information
Davier committed Mar 14, 2021
1 parent 01bb68b commit de55e05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_scene/src/dynamic_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl DynamicScene {
for component in scene_entity.components.iter() {
let registration = type_registry
.get_with_name(component.type_name())
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
.ok_or_else(|| SceneSpawnError::UnregisteredType {
type_name: component.type_name().to_string(),
})?;
let reflect_component =
Expand Down
10 changes: 8 additions & 2 deletions crates/bevy_scene/src/scene_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,15 @@ impl SceneSpawner {

let reflect_component = type_registry
.get(component_info.type_id().unwrap())
.and_then(|registration| registration.data::<ReflectComponent>())
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
.ok_or_else(|| SceneSpawnError::UnregisteredType {
type_name: component_info.name().to_string(),
})
.and_then(|registration| {
registration.data::<ReflectComponent>().ok_or_else(|| {
SceneSpawnError::UnregisteredComponent {
type_name: component_info.name().to_string(),
}
})
})?;
reflect_component.copy_component(
&scene.world,
Expand Down

0 comments on commit de55e05

Please sign in to comment.