classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: improve error handling in String


From: David Daney
Subject: Re: [cp-patches] Patch: improve error handling in String
Date: Thu, 15 Sep 2005 09:24:33 -0700
User-agent: Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720)

Tom Tromey wrote:
"David" == David Daney <address@hidden> writes:


David> Anthony Green wrote:

-         // XXX - Ignore coding exceptions? They shouldn't really happen.
-         return null;
+         // This shouldn't really happen.
+         throw new Error(e);


David> Whould it be better to use InternalError?  That is a little
David> more specific.

Yeah, I thought we had a rule about this, but I can't find it now.  I
think InternalError makes sense here (and furthermore should be in
hacking.texinfo).  Comments?

You are preaching to the choir here, but:

My personal preference is that we should never throw any of: Throwable, Exception, RuntimeException, or Error. There is always a reason why we are throwing. This reason should be reflected in the type being thrown.

Too bad if the type that should be thrown does not have a constructor that takes a chained Throwable as its cause. If this is the case use Throwable.initCause(). There is a reason that this method exists: It is so that we can use it to report the best information available about what went wrong.


Just MHO,
David Daney




reply via email to

[Prev in Thread] Current Thread [Next in Thread]