Skip to content

Commit

Permalink
replaced RuntimeException by MathRuntimeException
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc Maisonobe committed Nov 3, 2008
1 parent 9e8e88d commit ea15217
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.io.Serializable;

import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.ode.nonstiff.AdaptiveStepsizeIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
Expand Down Expand Up @@ -314,8 +315,7 @@ public void setInterpolatedTime(final double time) {
steps.get(index).setInterpolatedTime(time);

} catch (DerivativeException de) {
throw new RuntimeException("unexpected DerivativeException caught: " +
de.getMessage());
throw new MathRuntimeException("unexpected exception caught", new Object[0], de);
}

}
Expand Down
Expand Up @@ -22,6 +22,7 @@

import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.DimensionMismatchException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.random.CorrelatedRandomVectorGenerator;
import org.apache.commons.math.random.JDKRandomGenerator;
Expand Down Expand Up @@ -269,7 +270,7 @@ public PointCostPair minimize(CostFunction f, int maxEvaluations,

} catch (DimensionMismatchException dme) {
// this should not happen
throw new RuntimeException("internal error");
throw new MathRuntimeException("unexpected exception caught", new Object[0], dme);
}

}
Expand Down
Expand Up @@ -17,19 +17,20 @@

package org.apache.commons.math.random;

import java.io.EOFException;
import java.io.Serializable;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.EOFException;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.math.stat.descriptive.SummaryStatistics;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.stat.descriptive.StatisticalSummary;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;

/**
* Implements <code>EmpiricalDistribution</code> interface. This implementation
Expand Down Expand Up @@ -110,7 +111,7 @@ public void load(double[] in) {
da.computeStats();
fillBinStats(in);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
throw new MathRuntimeException(e);
}
loaded = true;

Expand Down Expand Up @@ -418,7 +419,7 @@ public double getNextValue() throws IllegalStateException {
}
}
}
throw new RuntimeException("No bin selected");
throw new MathRuntimeException("no bin selected", new Object[0]);
}

/**
Expand Down
Expand Up @@ -26,6 +26,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;

import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.RetryTestCase;
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
Expand Down Expand Up @@ -141,7 +142,11 @@ public void testNexFail() {
empiricalDistribution.getNextValue();
empiricalDistribution2.getNextValue();
fail("Expecting IllegalStateException");
} catch (IllegalStateException ex) {;}
} catch (IllegalStateException ex) {
// expected
} catch (Exception e) {
fail("wrong exception caught");
}
}

/**
Expand Down Expand Up @@ -190,9 +195,10 @@ public void testLoadNullDoubleArray() {
try {
dist.load((double[]) null);
fail("load((double[]) null) expected RuntimeException");
}
catch (RuntimeException e) {
} catch (MathRuntimeException e) {
// expected
} catch (Exception e) {
fail("wrong exception caught");
}
}

Expand All @@ -201,9 +207,10 @@ public void testLoadNullURL() throws Exception {
try {
dist.load((URL) null);
fail("load((URL) null) expected NullPointerException");
}
catch (NullPointerException e) {
} catch (NullPointerException e) {
// expected
} catch (Exception e) {
fail("wrong exception caught");
}
}

Expand All @@ -212,9 +219,10 @@ public void testLoadNullFile() throws Exception {
try {
dist.load((File) null);
fail("load((File) null) expected NullPointerException");
}
catch (NullPointerException e) {
} catch (NullPointerException e) {
// expected
} catch (Exception e) {
fail("wrong exception caught");
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/test/org/apache/commons/math/util/TestBean.java
Expand Up @@ -17,6 +17,8 @@

package org.apache.commons.math.util;

import org.apache.commons.math.MathRuntimeException;

/**
* @version $Revision$ $Date$
*/
Expand Down Expand Up @@ -57,7 +59,7 @@ public void setY(String string) {
*
*/
public Double getZ() {
throw new RuntimeException();
throw new MathRuntimeException();
}

/**
Expand Down

0 comments on commit ea15217

Please sign in to comment.