added MathInternalError
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X@1061496 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
045305d491
commit
1264fc3c07
|
@ -48,6 +48,7 @@ public class MathIllegalStateException extends IllegalStateException implements
|
|||
private final Object[] arguments;
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
* @param specific Message pattern providing the specific context of
|
||||
* the error.
|
||||
* @param general Message pattern explaining the cause of the error.
|
||||
|
@ -56,17 +57,46 @@ public class MathIllegalStateException extends IllegalStateException implements
|
|||
public MathIllegalStateException(Localizable specific,
|
||||
Localizable general,
|
||||
Object ... args) {
|
||||
this(null, specific, general, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
* @param cause root cause
|
||||
* @param specific Message pattern providing the specific context of
|
||||
* the error.
|
||||
* @param general Message pattern explaining the cause of the error.
|
||||
* @param args Arguments.
|
||||
*/
|
||||
public MathIllegalStateException(Throwable cause,
|
||||
Localizable specific,
|
||||
Localizable general,
|
||||
Object ... args) {
|
||||
super(cause);
|
||||
this.specific = specific;
|
||||
this.general = general;
|
||||
arguments = ArgUtils.flatten(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param general Message pattern explaining the cause of the error.
|
||||
* @param args Arguments.
|
||||
*/
|
||||
public MathIllegalStateException(Localizable general,
|
||||
Object ... args) {
|
||||
this(null, general, args);
|
||||
this(null, null, general, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
* @param cause root cause
|
||||
* @param general Message pattern explaining the cause of the error.
|
||||
* @param args Arguments.
|
||||
*/
|
||||
public MathIllegalStateException(Throwable cause,
|
||||
Localizable general,
|
||||
Object ... args) {
|
||||
this(cause, null, general, args);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math.exception;
|
||||
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
|
||||
/**
|
||||
* Exception triggered when something that shouldn't happen does happen.
|
||||
*
|
||||
* @since 2.2
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
public class MathInternalError extends MathIllegalStateException {
|
||||
|
||||
/** Serializable version Id. */
|
||||
private static final long serialVersionUID = -6276776513966934846L;
|
||||
|
||||
/** URL for reporting problems. */
|
||||
private static final String REPORT_URL = "https://issues.apache.org/jira/browse/MATH";
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
*/
|
||||
public MathInternalError() {
|
||||
super(LocalizedFormats.INTERNAL_ERROR, REPORT_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
* @param cause root cause
|
||||
*/
|
||||
public MathInternalError(final Throwable cause) {
|
||||
super(LocalizedFormats.INTERNAL_ERROR, REPORT_URL);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,16 +19,12 @@ package org.apache.commons.math.random;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math.distribution.BetaDistributionImpl;
|
||||
import org.apache.commons.math.distribution.BinomialDistributionImpl;
|
||||
import org.apache.commons.math.distribution.CauchyDistributionImpl;
|
||||
|
@ -42,8 +38,12 @@ import org.apache.commons.math.distribution.PascalDistributionImpl;
|
|||
import org.apache.commons.math.distribution.TDistributionImpl;
|
||||
import org.apache.commons.math.distribution.WeibullDistributionImpl;
|
||||
import org.apache.commons.math.distribution.ZipfDistributionImpl;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
import org.apache.commons.math.exception.MathInternalError;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implements the {@link RandomData} interface using a {@link RandomGenerator}
|
||||
|
@ -258,7 +258,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
alg = MessageDigest.getInstance("SHA-1");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
// this should never happen
|
||||
throw MathRuntimeException.createInternalError(ex);
|
||||
throw new MathInternalError(ex);
|
||||
}
|
||||
alg.reset();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Arrays;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.MathInternalError;
|
||||
import org.apache.commons.math.random.RandomData;
|
||||
import org.apache.commons.math.random.RandomDataImpl;
|
||||
import org.apache.commons.math.random.RandomGenerator;
|
||||
|
@ -211,7 +211,7 @@ public class NaturalRanking implements RankingAlgorithm {
|
|||
nanPositions = getNanPositions(ranks);
|
||||
break;
|
||||
default: // this should not happen unless NaNStrategy enum is changed
|
||||
throw MathRuntimeException.createInternalError(null);
|
||||
throw new MathInternalError();
|
||||
}
|
||||
|
||||
// Sort the IntDoublePairs
|
||||
|
@ -359,7 +359,7 @@ public class NaturalRanking implements RankingAlgorithm {
|
|||
}
|
||||
break;
|
||||
default: // this should not happen unless TiesStrategy enum is changed
|
||||
throw MathRuntimeException.createInternalError(null);
|
||||
throw new MathInternalError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue