Why exceptions for error handling is so important

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 09:36:28 PST 2015


"weaselcat" <weaselcat at gmail.com> wrote:
> On Monday, 12 January 2015 at 07:09:54 UTC, Tobias Müller wrote:
>> - Error codes are automatically ignored
>> - Exceptions are automatically propagated
>> 
>> IMO both are not ideal and lead to sloppy programming.
>> Ignoring errors is of course worse than aborting where you > could have
>> handled the error.
>> 
>> Rust-style "packed" errors are nice because you are forced to > think about
>> the correct handling.
> 
> There's nothing stopping you from just throwing errors out in Rust(last I
> used it anyways) via empty match statements and/or unwrap.

But you have to do so explicitly. You cannot just remove every possibility
to ignore errors, because sometimes it is justified.

BTW: 'unwrap' panics if it contains an error. But that's not really
important here.


More information about the Digitalmars-d mailing list