15 | | This kind of error handling method is used when the programmer has to handle situations that could go wrong, but shouldn't. This does not count obvious C++ programming mistakes! (see Assertions below) [[br]] |
16 | | 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 to the programmer to display the error at the right position. But you can still open the log and search for it unless the log debug level is below 4. [[br]][[br]] |
| 15 | This kind of error handling method is used when the programmer has to handle situations that could go wrong, but shouldn't. Mind the difference to Assertions below! [[br]] |
| 16 | For information about how to use them, see [wiki:Exception Exceptions]. [[br]] |
| 17 | A good example for exceptions would be a script compiler. Whenever it encounters bad tokens, it throws an exception with a message. The function calling the parser can then catch that exception, display it and act accordingly. [[br]] |
| 18 | We also use Exceptions when loading a level. If one occurs, we can abort and the user can choose another level. Of course this shouldn't happen, but nobody's perfect. [[br]][[br]] |
| 19 | Keep in mind that you yourself have to display the exception message at the right spot (they do get displayed automatically in level 4 however). |
18 | | 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. [[br]] |
19 | | Currently available types are: [[br]] |
20 | | || Name || Description || |
21 | | || || || |
22 | | || General || Anything. Avoid using it and rather define a new one. || |
23 | | || FileNotFound || Obviously a file was not found || |
24 | | || Argument || A function argument in a parser was wrong. || |
25 | | || PluginsNotFound || No Ogre plugins were found but are required || |
26 | | || InitialisationFailed || When starting the game engine, something went terribly wrong. || |
27 | | || NotImplemented || The feature requested has not yet been implemented || |
28 | | || GameState || Something went wrong with a GameState class || |
29 | | [[br]] |