From 08042a0c22ab360a04fbe96c6bb8096f1560c2e6 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Mon, 12 Feb 2007 19:35:59 +0000 Subject: [PATCH] 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 --- .../commons/math/analysis/UnivariateRealSolverUtils.java | 9 ++++----- .../distribution/AbstractContinuousDistribution.java | 3 +-- .../org/apache/commons/math/util/DefaultTransformer.java | 7 ++++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtils.java b/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtils.java index 89267e5ca..c649c0194 100644 --- a/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtils.java +++ b/src/java/org/apache/commons/math/analysis/UnivariateRealSolverUtils.java @@ -198,11 +198,10 @@ public class UnivariateRealSolverUtils { if (fa * fb >= 0.0 ) { throw new ConvergenceException - ("Number of iterations= " + numIterations + - " maximum iterations= " + maximumIterations + - " initial= " + initial + " lowerBound=" + lowerBound + - " upperBound=" + upperBound + " final a value=" + a + - " final b value=" + b + " f(a)=" + fa + " f(b)=" + fb); + ("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}", + new Object[] { new Integer(numIterations), new Integer(maximumIterations), + new Double(initial), new Double(lowerBound), new Double(upperBound), + new Double(a), new Double(b), new Double(fa), new Double(fb) }); } return new double[]{a, b}; diff --git a/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java b/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java index 1c1e19c99..c8b323b6e 100644 --- a/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java +++ b/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java @@ -71,8 +71,7 @@ public abstract class AbstractContinuousDistribution try { return cumulativeProbability(x) - p; } catch (MathException ex) { - throw new FunctionEvaluationException - (x, "Error computing cdf", ex); + throw new FunctionEvaluationException(x, ex.getPattern(), ex.getArguments(), ex); } } }; diff --git a/src/java/org/apache/commons/math/util/DefaultTransformer.java b/src/java/org/apache/commons/math/util/DefaultTransformer.java index 9a57e8fa2..bb610e8ec 100644 --- a/src/java/org/apache/commons/math/util/DefaultTransformer.java +++ b/src/java/org/apache/commons/math/util/DefaultTransformer.java @@ -44,7 +44,7 @@ public class DefaultTransformer implements NumberTransformer, Serializable { public double transform(Object o) throws MathException{ 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) { @@ -54,7 +54,8 @@ public class DefaultTransformer implements NumberTransformer, Serializable { try { return new Double(o.toString()).doubleValue(); } 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); } } -} \ No newline at end of file +}