use properly the top level exceptions for too specific cases which don't need a devoted exception class

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@506600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2007-02-12 19:35:59 +00:00
parent ee556907bb
commit 08042a0c22
3 changed files with 9 additions and 10 deletions

View File

@ -198,11 +198,10 @@ public class UnivariateRealSolverUtils {
if (fa * fb >= 0.0 ) { if (fa * fb >= 0.0 ) {
throw new ConvergenceException throw new ConvergenceException
("Number of iterations= " + numIterations + ("Number of iterations={0}, maximum iterations={1}, initial={2}, lower bound={3}, upper bound={4}, final a value={5}, final b value={6}, f(a)={7}, f(b)={8}",
" maximum iterations= " + maximumIterations + new Object[] { new Integer(numIterations), new Integer(maximumIterations),
" initial= " + initial + " lowerBound=" + lowerBound + new Double(initial), new Double(lowerBound), new Double(upperBound),
" upperBound=" + upperBound + " final a value=" + a + new Double(a), new Double(b), new Double(fa), new Double(fb) });
" final b value=" + b + " f(a)=" + fa + " f(b)=" + fb);
} }
return new double[]{a, b}; return new double[]{a, b};

View File

@ -71,8 +71,7 @@ public abstract class AbstractContinuousDistribution
try { try {
return cumulativeProbability(x) - p; return cumulativeProbability(x) - p;
} catch (MathException ex) { } catch (MathException ex) {
throw new FunctionEvaluationException throw new FunctionEvaluationException(x, ex.getPattern(), ex.getArguments(), ex);
(x, "Error computing cdf", ex);
} }
} }
}; };

View File

@ -44,7 +44,7 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
public double transform(Object o) throws MathException{ public double transform(Object o) throws MathException{
if (o == null) { if (o == null) {
throw new MathException("Conversion Exception in Transformation, Object is null"); throw new MathException("Conversion Exception in Transformation, Object is null", new Object[0]);
} }
if (o instanceof Number) { if (o instanceof Number) {
@ -54,7 +54,8 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
try { try {
return new Double(o.toString()).doubleValue(); return new Double(o.toString()).doubleValue();
} catch (Exception e) { } catch (Exception e) {
throw new MathException("Conversion Exception in Transformation: " + e.getMessage(), e); throw new MathException("Conversion Exception in Transformation: {0}",
new Object[] { e.getMessage() }, e);
} }
} }
} }