commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject [math] Restoring IAE to MathUtils#binomialCoefficient methods
Date Sat, 30 Apr 2011 16:10:08 GMT
Converting some of my code to use trunk, I discovered that the
binomialCoefficient methods no longer throw IllegalArgumentException
when parameters are invalid.  The javadoc asserts that
MathIllegalArgumentException will be thrown in these cases, but that
is not correct, since what is actually thrown now can differ
depending on the parameter problem and the resulting exceptions are
neither standard IAEs nor descendents of MathIAE.  I have patched
the code to return a standard IAE (with localized message).  Per
discussion in [1] it looks like we were close to consensus to favor
standard exceptions and in this case, I would much rather return a
standard IAE with meaningful error message rather than a
non-standard RTE (with exactly the same error message and generally
confusing type - e.g. "NumberIsTooSmall" when n, k parameters are
not in the right order) and keep the javadoc simple.  Otherwise, the
main method javadoc has to be rewritten to conform to what the code
now does.

Are there any objections to this change?

Phil

[1] *http://s.apache.org/nr*

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


Mime
View raw message