commons-dev mailing list archives

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

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

Welcome.

> and decided to grab something easy to
> attempt. I decided to take a shot at:
> https://issues.apache.org/jira/browse/NUMBERS-40.

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 
that
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
package-private).
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.


Regards,
Gilles

>
> What do you guys think?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message