core: Add assert and debugging message to catch ObjectFactory errors
This commit is contained in:
committed by
Tommaso Pecorella
parent
2f160894a6
commit
27aa41e454
@@ -93,6 +93,9 @@ Ptr<Object>
|
||||
ObjectFactory::Create() const
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
NS_ASSERT_MSG(
|
||||
m_tid.GetUid(),
|
||||
"ObjectFactory::Create - can't use an ObjectFactory without setting a TypeId first.");
|
||||
Callback<ObjectBase*> cb = m_tid.GetConstructor();
|
||||
ObjectBase* base = cb();
|
||||
auto derived = dynamic_cast<Object*>(base);
|
||||
|
||||
@@ -457,7 +457,8 @@ IidManager::IidInformation*
|
||||
IidManager::LookupInformation(uint16_t uid) const
|
||||
{
|
||||
NS_LOG_FUNCTION(IID << uid);
|
||||
NS_ASSERT(uid <= m_information.size() && uid != 0);
|
||||
NS_ASSERT_MSG(uid <= m_information.size() && uid != 0,
|
||||
"The uid " << uid << " for this TypeId is invalid");
|
||||
NS_LOG_LOGIC(IIDL << m_information[uid - 1].name);
|
||||
return const_cast<IidInformation*>(&m_information[uid - 1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user