exceptions vs error codes

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 13 06:50:00 PDT 2016


On Wednesday, 13 July 2016 at 13:46:44 UTC, Chris Wright wrote:
> On Wed, 13 Jul 2016 13:31:03 +0000, ketmar wrote:
>
>> On Wednesday, 13 July 2016 at 13:13:45 UTC, Chris Wright wrote:
>> as Error can be thrown anywhere along the way (think, for 
>> example, about
>> RangeError in expression with side-effects), and stack 
>> unwinding is not
>> guaranteed (but *may* happen, and may happen partially), the 
>> program
>> *is* in undefined state. that is why Errors aren't usual 
>> Exceptions, and
>> that is why you should not assume *anything* after Error is 
>> thrown.
>
> Point to the place in the spec that it says that this is true 
> of Error and not other Throwables.

https://dlang.org/library/object/throwable.html

"In principle, one should not catch Throwable objects that are 
not derived from Exception, as they represent unrecoverable 
runtime errors. Certain runtime guarantees may fail to hold when 
these errors are thrown, making it unsafe to continue execution 
after catching them."


More information about the Digitalmars-d mailing list