From 30702d94f65a2bd86c9ac0a7c402675b89ac4364 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 6 Oct 2023 15:23:36 -0500 Subject: fix QueryDoesNotMatch and improve error --- azalea-client/src/entity_query.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'azalea-client/src/entity_query.rs') diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index ca41c872..7b140825 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -23,9 +23,10 @@ impl Client { /// # } /// ``` pub fn query<'w, Q: WorldQuery>(&self, ecs: &'w mut World) -> ::Item<'w> { - ecs.query::() - .get_mut(ecs, self.entity) - .expect("Our client is missing a required component.") + ecs.query::().get_mut(ecs, self.entity).expect(&format!( + "Our client is missing a required component {:?}", + std::any::type_name::() + )) } /// Return a lightweight [`Entity`] for the entity that matches the given @@ -66,9 +67,10 @@ impl Client { pub fn entity_component(&mut self, entity: Entity) -> Q { let mut ecs = self.ecs.lock(); let mut q = ecs.query::<&Q>(); - let components = q - .get(&ecs, entity) - .expect("Entity components must be present in Client::entity)components."); + let components = q.get(&ecs, entity).expect(&format!( + "Entity is missing a required component {:?}", + std::any::type_name::() + )); components.clone() } -- cgit v1.2.3