Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 5 and Version 6 of code/Error_handling


Ignore:
Timestamp:
Apr 12, 2017, 10:15:42 PM (7 years ago)
Author:
landauf
Comment:

fixed links

Legend:

Unmodified
Added
Removed
Modified
  • code/Error_handling

    v5 v6  
    11= Error handling in Orxonox =
    2 [[TracNav(TracNav/TOC_Development)]]
    32
    43Whenever something unwanted happens, the programmer needs to react in a certain way.[[br]]
     
    109
    1110== orxout(#), displays messages ==
    12 Whenever you want to show the user or the programmer a message, use orxout(#) where # is the level of your output. See [wiki:Output] for more information. [[br]]
     11Whenever you want to show the user or the programmer a message, use orxout(#) where # is the level of your output. See [wiki:doc/Output] for more information. [[br]]
    1312
    1413'''Note: A simple message with level user_error (or internal_error) doesn't trigger an exception or anything yet'''
     
    1615== Exceptions ==
    1716This 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]]
    18 For information about how to use them, see [wiki:Exception Exceptions]. [[br]]
     17For information about how to use them, see [wiki:doc/Exception Exceptions]. [[br]]
    1918A 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]]
    2019We 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]]
     
    3938'''Important: Asserts are only useful when the mistake is in the program. Throwing asserts for bad input doesn't help anyone, use exceptions then! [[br]]
    4039
    41 Usage: 'assert(condition you assume);' or when you want to tell more use 'OrxAssert(condition, message)'. The message gets then displayed via orxout(user_error) before the assert() macro is called. [[br]]
     40Usage: 'assert(condition you assume);' or when you want to tell more use '!OrxAssert(condition, message)'. The message gets then displayed via orxout(user_error) before the assert() macro is called. [[br]]
    4241The example above would then read:
    4342