Details

Type: Improvement

Status: Closed

Priority: Minor

Resolution: Fixed

Affects Version/s: None

Fix Version/s: 3.0

Labels:None
Description
The checked "ConvergenceException" should be deprecated.
An example usage is in class ContinuedFraction (package util), at line 153:
if (scale <= 0) { // Can't scale throw new ConvergenceException(LocalizedFormats.CONTINUED_FRACTION_INFINITY_DIVERGENCE, x); }
I think that it should be replaced by a more specific (and unchecked) exception that reflects the exact lowlevel problem:
if (scale <= 0) { // Can't scale throw new NotStrictlypositiveException(scale); }
A few lines below that, there is:
if (infinite) { // Scaling failed throw new ConvergenceException(LocalizedFormats.CONTINUED_FRACTION_INFINITY_DIVERGENCE, x); }
So it seems that it is not necessary to throw an exception at the place where the test on "scale" fails; instead we could have:
infinite = true; if (scale <= 0) { // Can't scale break; }
and let the check on "infinite" throw the exception:
if (infinite) { // Scaling failed throw new NotFiniteNumberException(LocalizedFormats.CONTINUED_FRACTION_DIVERGENCE, Double.POSITIVE_INFINITY, x); }
As shown in the above excerpt, we could also replace two enum:
 CONTINUED_FRACTION_INFINITY_DIVERGENCE
 CONTINUED_FRACTION_NAN_DIVERGENCE
with a single one:
 CONTINUED_FRACTION_DIVERGENCE
because the other bit of information (infinity vs NaN) is already given by the first parameter of the message.
What do you think of these changes?