Ogre::Any floods log when object cannot be casted

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Ogre::Any floods log when object cannot be casted

Post by Lax »

Hi,

I'm testing the new getUserObjectBindings().getUserAny() function. I have noticed that when an object cannot be casted, the log is flooded with exception messages:

21:32:19: OGRE EXCEPTION(2:InvalidParametersException): Bad cast from type 'void' to 'class NOWA::GameObject *' in Ogre::any_cast at d:\ogre\gameenginedevelopment\external\ogre2.1sdk\ogremain\include\ogreany.h (line 411)
21:32:19: OGRE EXCEPTION(2:InvalidParametersException): Bad cast from type 'void' to 'class NOWA::GameObject *' in Ogre::any_cast at d:\ogre\gameenginedevelopment\external\ogre2.1sdk\ogremain\include\ogreany.h (line 411)
...

I think, if an object cannot be casted, obviously its not the correct object, so skip that. I got rid of the exception by calling:

Code: Select all

NOWA::GameObject* gameObject = nullptr;
try
{
	gameObject = Ogre::any_cast<NOWA::GameObject*>(movableObject->getUserObjectBindings().getUserAny());
}
catch (Ogre::Exception& error)
{

}
if (nullptr != gameObject)
{
   ...
}
So my question is, would it be possible to leave the log message out, maybe by a default bool parameter?

Best regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Post Reply