Skip to content

Commit 12da4e4

Browse files
authored
Add parent ID to the B0004 log message (#19980)
# Objective Minor CL to add parent entity ID to the B0004 error message to improve debugging.
1 parent eb6afd2 commit 12da4e4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

crates/bevy_ecs/src/hierarchy.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,13 @@ pub fn validate_parent_has_component<C: Component>(
455455
let Some(child_of) = entity_ref.get::<ChildOf>() else {
456456
return;
457457
};
458-
if !world
459-
.get_entity(child_of.parent())
460-
.is_ok_and(|e| e.contains::<C>())
461-
{
458+
let parent = child_of.parent();
459+
if !world.get_entity(parent).is_ok_and(|e| e.contains::<C>()) {
462460
// TODO: print name here once Name lives in bevy_ecs
463461
let name: Option<String> = None;
464462
let debug_name = DebugName::type_name::<C>();
465463
warn!(
466-
"warning[B0004]: {}{name} with the {ty_name} component has a parent without {ty_name}.\n\
464+
"warning[B0004]: {}{name} with the {ty_name} component has a parent ({parent}) without {ty_name}.\n\
467465
This will cause inconsistent behaviors! See: https://bevy.org/learn/errors/b0004",
468466
caller.map(|c| format!("{c}: ")).unwrap_or_default(),
469467
ty_name = debug_name.shortname(),

0 commit comments

Comments
 (0)