Skip to content

Commit

Permalink
QueryEntityError: Use short name for components (#16032)
Browse files Browse the repository at this point in the history
Use the new `disqualified` crate in `QueryEntityError` to make the error
message more readable.

---

## Showcase

Old:
QueryDoesNotMatch(0v1 with components my_game::main::foo::A,
my_game::main::foo::B, bevy_pbr::light::point_light::PointLight,
bevy_render::primitives::CubemapFrusta,
bevy_pbr::bundle::CubemapVisibleEntities,
bevy_transform::components::transform::Transform,
bevy_transform::components::global_transform::GlobalTransform,
bevy_render::view::visibility::Visibility,
bevy_render::view::visibility::InheritedVisibility,
bevy_render::view::visibility::ViewVisibility,
bevy_render::sync_world::SyncToRenderWorld)

New:
QueryDoesNotMatch(0v1 with components A, B, PointLight, CubemapFrusta,
CubemapVisibleEntities, Transform, GlobalTransform, Visibility,
InheritedVisibility, ViewVisibility, SyncToRenderWorld)

---------

Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
SpecificProtagonist and alice-i-cecile authored Oct 20, 2024
1 parent b0fd3d5 commit 3eec0f0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/bevy_ecs/src/query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn format_archetype(
.components()
.get_name(component_id)
.expect("entity does not belong to world");
write!(f, "{name}")?;
write!(f, "{}", disqualified::ShortName(name))?;
}
Ok(())
}
Expand Down Expand Up @@ -126,6 +126,9 @@ mod test {
.get(&world, entity)
.unwrap_err();

assert_eq!(format!("{err:?}"), "QueryDoesNotMatch(0v1 with components bevy_ecs::query::error::test::query_does_not_match::Present1, bevy_ecs::query::error::test::query_does_not_match::Present2)");
assert_eq!(
format!("{err:?}"),
"QueryDoesNotMatch(0v1 with components Present1, Present2)"
);
}
}

0 comments on commit 3eec0f0

Please sign in to comment.