add more informative "resource does not exist" errors

This commit is contained in:
Carter Anderson 2020-07-11 20:12:34 -07:00
parent f4fe9abda8
commit 86f41ae0a4

View File

@ -140,7 +140,7 @@ impl Resources {
let archetype = self let archetype = self
.resource_archetypes .resource_archetypes
.get(&TypeId::of::<T>()) .get(&TypeId::of::<T>())
.expect("Resource does not exist"); .unwrap_or_else(|| panic!("Resource does not exist {}", std::any::type_name::<T>()));
Res::new(archetype, 0).expect("Resource does not exist") Res::new(archetype, 0).expect("Resource does not exist")
} }
@ -149,7 +149,7 @@ impl Resources {
let archetype = self let archetype = self
.resource_archetypes .resource_archetypes
.get(&TypeId::of::<T>()) .get(&TypeId::of::<T>())
.expect("Resource does not exist"); .unwrap_or_else(|| panic!("Resource does not exist {}", std::any::type_name::<T>()));
ResMut::new(archetype, 0).expect("Resource does not exist") ResMut::new(archetype, 0).expect("Resource does not exist")
} }
} }