Exception/Error division in D

Walter Bright newshound2 at digitalmars.com
Thu May 31 17:57:13 PDT 2012


On 5/31/2012 2:23 AM, Lars T. Kyllingstad wrote:
> On Thursday, 31 May 2012 at 02:18:22 UTC, Walter Bright wrote:
>> A recoverable exception is NOT a logic bug in your program, which is why it is
>> recoverable.
>>
>> If there is recovery possible from a particular assert error, then you are
>> using asserts incorrectly.
>
> I think this is a key point. Asserts are there to verify and debug program
> logic, they are not part of the logic itself. They are a useful tool for the
> programmer, nothing more. Specifically, asserts are NOT an error handling
> mechanism!

Right. And I'd like to amplify that the asserts are also there to detect program 
faults hopefully before damage is done.

If a program must continue even after it has failed, then you have a WRONGLY 
designed system.

It is extremely important to understand this point if you are implementing any 
sort of critical software.


More information about the Digitalmars-d mailing list