The recommendation is that you at least do an assert to verify that the return code is not negative after each call. That way when running the application in debug mode the debugger will immediately on the call that caused the error, thus making it easy to find problems.
For example, take a look at how the std::string is registered in the add-on:
r = engine->RegisterObjectType("string", sizeof(string), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructString), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f(const string &in)", asFUNCTION(CopyConstructString), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("string", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructString), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "string &opAssign(const string &in)", asMETHODPR(string, operator =, (const string&), string&), asCALL_THISCALL); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "string &opAddAssign(const string &in)", asFUNCTION(AddAssignStringToString), asCALL_CDECL_OBJLAST); assert( r >= 0 );
I see you have registered the message callback, but alone it will not be able to tell you which call caused the error. I've tried to make the engine provide as much information as possible about the cause, but without checking the return code for each call it can be very difficult to locate the error.
Once you find the call that gives the error, I'm pretty sure you'll soon figure out how to fix the problem. If not, please post more detailed information about the problem so we can provide more specific help.
Regards,
Andreas