DIP33: A standard exception hierarchy

deadalnix deadalnix at gmail.com
Tue Apr 2 03:37:06 PDT 2013


On Monday, 1 April 2013 at 11:08:16 UTC, Lars T. Kyllingstad 
wrote:
> It's time to clean up this mess.
>
> http://wiki.dlang.org/DIP33

Several things.

First the usage of enums isn't the right path. This makes it hard 
to extend in general, and it is a poor man replacement for sub 
classes in general.

As a rule of thumb, when you use switch in OOP code, you are 
likely to do something wrong.

Second, many of you error are recoverable here. It isn't quite 
satisfying.

RangeError is a very bad thing IMO. It completely hides why the 
range fails in the first place. Trying to access front when not 
possible for instance, is an error for a reason (which is range 
dependent). That reason must be the source of the error/exception.

In general the hierarchy is weird. Why isn't NetworkingException 
(why not NetworkException ?) a subclass of IOException ?

OutOfMemoryError on its own isn't good IMO. The Error hierarchy 
is made for error that aren't recoverable (or may not be 
recoverable). It include a whole class of problem, and OOM is 
only one of them (another example is Stack overflow errors).


More information about the Digitalmars-d mailing list