From 3eec0f0a7748b848b2856be9977c51168789775a Mon Sep 17 00:00:00 2001 From: SpecificProtagonist Date: Sun, 20 Oct 2024 19:56:43 +0200 Subject: [PATCH] QueryEntityError: Use short name for components (#16032) 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 --- crates/bevy_ecs/src/query/error.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/query/error.rs b/crates/bevy_ecs/src/query/error.rs index 90df07b6a9308..9adf7d542c59a 100644 --- a/crates/bevy_ecs/src/query/error.rs +++ b/crates/bevy_ecs/src/query/error.rs @@ -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(()) } @@ -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)" + ); } }