Clearer error messages instead of 'assertion failed' for RTTI errors


Hi there,

It has occurred to me that you often get an ‘assertion failed’ error before initialisation, at some line in the cpp code of nap, when something is wrong with rtti definitions.

For example, when you forget to add RTTI_ENABLE() to an rtti defined class, you get:

Assertion failed: (component_instance), function createEntityInstance, file /Users/macbook/Documents/Repositories/nap/modules/napscene/src/scene.cpp, line 522.

These errors are hard to debug, because they give no additional information about the type of problem or about which class causes it.

I was wondering if it would be possible to create clearer error messages for these cases, that communicate the cause and the location of the problem to the programmer.



Hey, sorry for the late reply on this one. I agree that better error messages as a result of serialization errors due to definition (or other) failures are important. That said: the assert is there for a reason because it’s simply not allowed to fail. I think we need to introduce a special assert that prints a message before throwing the assert, this will resolve your issue. I’ll make a ticket for it.


In the new NAP release (0.4) we added the option to trigger an assert that prints a message to console using the following syntax:

NAP_ASSERT_MSG(false, "Intentional Assert")

I updated the source code to make use of this assert when necessary or useful.