[phobos] Why ConvError and not ConvException?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Nov 16 16:03:44 PST 2010
On Tuesday, November 16, 2010 14:45:39 Shin Fujishiro wrote:
> Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > On Tuesday 16 November 2010 12:41:29 Shin Fujishiro wrote:
> > > 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.
>
> Yeah, I agree that suffixed Exceptions are very clear. I wrote it
> because std.concurrency has non-suffixed exceptions such as
> MessageMismatch, which are still clear thanks to negative terms
> embedded in their names.
Well, then I'd argue that those exception classes should have their names
changed to include Exception, but the negative terms embedded in their names do
make them work as they are. It's just inconsistent, and generally-speaking, such
inconsistencies in a library should be avoided unless there's a good, overriding
reason to have them.
- Jonathan M Davis
More information about the phobos
mailing list