commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <>
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?


[1] **

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

View raw message