commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <>
Subject Re: NUMBERS-40: Review exception usage in package "o.a.c.numbers.gamma"
Date Thu, 08 Jun 2017 10:13:44 GMT

On Wed, 7 Jun 2017 17:00:46 -0500, Tharaka De Silva wrote:
> Hello everyone,
> I am new to the ASF community


> and decided to grab something easy to
> attempt. I decided to take a shot at:

Easy to change is not always similar to easy to decide what
changes to perform. ;-)

> The rationale of implementing this design would be this:
> GammaException is currently a subclass of IllegalArgumentException 
> but the
> reason for an argument to be invalid would be because it is 
> arithmetically
> impossible hence why it should be an ArithmeticException rather than 
> a
> IllegalArgumentException.

In quite a few cases, it is actually _not_ "arithmetically impossible",
it is a limitation of the implementation.

The JIRA report asks whether it is possible to use a single exception
type (currently "GammaException") for all programming errors, given 
the base class of all errors _cannot_ be "ArithmeticException" (as the
above explains).

As an aside, in the unit tests, the use of the exception's base (JDK)
class in the "expected" clause is intentional as the unit tests are
mainly supposed to  check the public API (and "GammaException" is
In "Commons Numbers", the idea would be to have a most simple exception
handling (throwing only JDK exceptions) since it is expected (TBC) that
all of them result from incorrect usage or bugs in the library.


> What do you guys think?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message