Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 1 and Version 2 of code/doc/Exception


Ignore:
Timestamp:
Sep 4, 2008, 2:26:22 PM (16 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Exception

    v1 v2  
    88
    99== COUT(#), displays messages ==
    10 Whenever you want to show the user or the programmer a message, use COUT(#) where # is a number denoting the output level:
    11 || # || Meaning ||
    12 || || ||
    13 || 0 || Gets always displayed and is mean for messages like "loading level 'foo.bar'" ||
    14 || 1 || Errors. Something seriously bad has happened. Mostly in combination with assert() or an exception. ||
    15 || 2 || Warnings. The issue is not too bad, but everyone should see that something bad has happened. ||
    16 || 3 || Slight debug information. Not intended to be displayed to the end-user, but surely every beta tester. ||
    17 || 4 || Debug information. Can be quite a lot of text. ||
    18 || 5 || Verbose debug information. That would be overkill in the shell or console. View the log! ||
    19 || 6 || Extreme debug information. You better use grep or another regex tool to read a log file for level 6. ||
    20 [[br]]
     10Whenever you want to show the user or the programmer a message, use COUT(#) where # is a number denoting the output [wiki:Debug level]. [[br]]
    2111
    22 You can configure the displayed levels for all output devices: Shell, console and log. Default value is around 3. There is also a possibility to define a hard debug level, so that the COUT(#) calls don't even get compiled above a that level. [[br]][[br]]
    2312'''Note: A simple message with level 1 doesn't trigger an exception or anything yet!'''
    2413
     
    5544You can now insert a call to the 'asser()' macro so that whenever ptr == 0 the program aborts. Now this doesn't sound very help, but it is: First of all, the abort message tells you exactly where the error has happened (file, line, function). Secondly, the program would have aborted anyway because of the null pointer. [[br]][[br]]
    5645The more asserts you insert, the easier bug tracking will be. You might even spot them before they could ever be triggered. [[br]][[br]]
    57 '''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]]
     46'''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]]
    5847
    5948Usage: 'assert(condition you assume);' or when you want to tell more use 'OrxAssert(condition, message)'. The message gets then displayed via COUT(1) before the assert() macro is called. [[br]]