You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2007/12/09 03:23:08 UTC
svn commit: r602612 -
/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
Author: psteitz
Date: Sat Dec 8 18:23:07 2007
New Revision: 602612
URL: http://svn.apache.org/viewvc?rev=602612&view=rev
Log:
Clean up reflection exception handling.
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java?rev=602612&r1=602611&r2=602612&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java Sat Dec 8 18:23:07 2007
@@ -17,6 +17,7 @@
package org.apache.commons.math.stat.descriptive;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import org.apache.commons.discovery.tools.DiscoverClass;
@@ -369,9 +370,15 @@
percentileImpl.getClass().getMethod("setQuantile",
new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {new Double(p)});
- } catch (Exception ex) { // Should never happen, guarded by setter
- throw new IllegalStateException(
- "Percentile implementation does not support setQuantile");
+ } catch (NoSuchMethodException e1) { // Setter guard should prevent
+ throw new IllegalArgumentException(
+ "Percentile implementation does not support setQuantile");
+ } catch (IllegalAccessException e2) {
+ throw new IllegalArgumentException(
+ "IllegalAccessException setting quantile");
+ } catch (InvocationTargetException e3) {
+ throw new IllegalArgumentException(
+ "Error setting quantile" + e3.toString());
}
}
return apply(percentileImpl);
@@ -503,9 +510,15 @@
percentileImpl.getClass().getMethod("setQuantile",
new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {new Double(50.0d)});
- } catch (Exception ex) {
+ } catch (NoSuchMethodException e1) {
throw new IllegalArgumentException(
"Percentile implementation does not support setQuantile");
+ } catch (IllegalAccessException e2) {
+ throw new IllegalArgumentException(
+ "IllegalAccessException setting quantile");
+ } catch (InvocationTargetException e3) {
+ throw new IllegalArgumentException(
+ "Error setting quantile" + e3.toString());
}
this.percentileImpl = percentileImpl;
}