Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 4 (modified by rgrieder, 16 years ago) (diff)

Exceptions

This article assumes that you know what an Exception is and how to throw it. Otherwise, see wikipedia or cpluscplus.com.

When an exception gets thrown, its message, containing file, line number, function name, exception type and programmer message, is displayed via COUT(4). That means you usually don't see them anywhere because it is better left up to the programmer to display the message at the right position. But you can still open the log and search for it unless the log debug level is below 4.

To throw an exception you best use the 'ThrowException(type, message)' macro that automatically adds line number, function and file name. 'Type' is a user defined derived class of orxonox::Exception so that different exceptions can be caught with different 'catch' clauses.
Currently available types are:

Name Description
General Anything. Avoid using it and rather define a new one.
FileNotFound Obviously a file was not found
Argument A function argument in a parser was wrong.
PluginsNotFound No Ogre plugins were found but are required
InitialisationFailed When starting the game engine, something went terribly wrong.
NotImplemented The feature requested has not yet been implemented
GameState Something went wrong with a GameState class