Adjusted panic msgs,  printing type names instead of their id
-use std::any::TypeId;
+use std::any::type_name;
use crate::{
css_engine::*,
@@ -50,10 +50,10 @@ impl<'a> WidgetContainer<'a> {
let name = self.get_name();
panic!(
- "Widget with name: {} and entity: {} does not contain property width type_id {:?} for key: {}",
+ "Widget: {} with entity: {} does not contain property with type {:?} for key: {}",
name,
self.current_node.0,
- TypeId::of::<P>(),
+ type_name::<P>(),
key
);
}
@@ -78,7 +78,7 @@ impl<'a> WidgetContainer<'a> {
panic!(
"Entity {} does not contain property type {:?}, with key: {}",
self.current_node.0,
- TypeId::of::<P>(),
+ type_name::<P>(),
key
);
}
@@ -112,10 +112,10 @@ impl<'a> WidgetContainer<'a> {
let name = self.get_name();
panic!(
- "Widget with name: {} and entity: {} does not contain property width type_id {:?} for key: {}",
+ "Widget: {} with entity: {} does not contain property with type {:?} for key: {}",
name,
self.current_node.0,
- TypeId::of::<P>(),
+ type_name::<P>(),
key
);
}
@@ -154,10 +154,10 @@ impl<'a> WidgetContainer<'a> {
let name = self.get_name();
panic!(
- "Widget with name: {} and entity: {} does not contain property width type_id {:?} for key: {}",
+ "Widget: {} with entity: {} does not contain property with type {:?} for key: {}",
name,
self.current_node.0,
- TypeId::of::<P>(),
+ type_name::<P>(),
key
);
}
@@ -424,11 +424,15 @@ impl<'a> WidgetContainer<'a> {
}
fn get_name(&self) -> String {
+ if self.has::<String>("name") {
self
.ecm
.component_store()
.get::<String>("name", self.current_node)
.unwrap()
.clone()
+ } else {
+ String::from("unknown")
+ }
}
}
