Why exceptions for error handling is so important

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 03:41:04 PST 2015


On 1/12/2015 3:27 AM, Dicebot wrote:
> .. and have many other issues instead :)
>
> Right now my experience from some quick experiments with Rust seems to indicate
> that it is a good sort inconvenience for medium-to-big applications as it forces
> you to explicitly consider all possible exceptional paths possible in
> application without and does not add any runtime overhead.
>
> For smaller / less important programs verbosity does seem inconvenient in an
> unpleasant way indeed.

For me the primary advantage of EH is put the code to deal with the error in the 
place where it is most appropriate to deal with it. With error codes, you have 
to deal with propagating the errors everywhere. Error codes still require manual 
insertion of unwinding code, and that can get fairly ugly when dealing with 
transactions:

   http://dlang.org/exception-safe.html

Scope guard and RAII deal with most of the issues with having correct error 
recovery.



More information about the Digitalmars-d mailing list