[phobos] Why ConvError and not ConvException?

Jonathan M Davis jmdavisProg at gmx.com
Tue Nov 16 13:00:10 PST 2010


On Tuesday 16 November 2010 12:41:29 Shin Fujishiro wrote:
> Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > On Monday 15 November 2010 19:44:50 Andrei Alexandrescu wrote:
> > > Historical reasons. I favor your implied change.
> > 
> > Enhancement request created:
> > http://d.puremagic.com/issues/show_bug.cgi?id=5220
> > 
> > Hopefully someone with write access can get around to it before the next
> > release - particularly since it should be a very quick and simple
> > change. In either case, this way it won't be forgotten.
> 
> Okay, replaced all ConvError with ConvException.
> 
> By the way, it feels redundant for me to name every exception class
> with an ending Exception, especially descriptive ones such as
> ConvOverflowException.  Couldn't it be ConversionOverflow?

It's clearer and more consistent to have Exception in the name. It makes it nice 
and obvious that you're dealing with an exception type, and it's not like youe 
have to type them very often anyway. Also, what would you do for stuff like 
std.datetime? It has DateTimeException. It's not like you can change it to 
DateTime. Not only would that be a bad name (since its name is not indicative of 
an exception or error at all), but there's already a separate DateTime type.

FWIW, all of the exceptions in Java have Exception in their name, and as far as 
I recall, every exception class that I've used in any other language has had 
Exception or exception in its name. It makes it nice and clear that you're 
dealing with an exception type, and while some might be able leave it out - like 
ConversionOverflow - that leads to inconsistency with all of the exception types 
which need it in order to make it clear that they're actually an error of some 
sort.

So, I definitely think that in Phobos and Druntime we should have Exception as 
the suffix for all Throwables descended from Exception and Error as the suffix for 
all Throwables descended from Error. It's clear and consistent that way.

- Jonathan M Davis


More information about the phobos mailing list