You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/11/29 00:44:23 UTC
svn commit: r1642375 -
/commons/proper/net/trunk/src/main/java/examples/Main.java
Author: sebb
Date: Fri Nov 28 23:44:23 2014
New Revision: 1642375
URL: http://svn.apache.org/r1642375
Log:
Don't show reflection wrapper in stack trace if exception was thrown by called code
Modified:
commons/proper/net/trunk/src/main/java/examples/Main.java
Modified: commons/proper/net/trunk/src/main/java/examples/Main.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/Main.java?rev=1642375&r1=1642374&r2=1642375&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/Main.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/Main.java Fri Nov 28 23:44:23 2014
@@ -18,6 +18,7 @@
package examples;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.CodeSource;
import java.util.Enumeration;
@@ -39,7 +40,7 @@ public class Main {
* @throws Exception
* @throws Exception
*/
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) throws Throwable {
if (args.length==0) {
System.out.println("Usage: java -jar commons-net-examples-m.n.jar <exampleClass> <exampleClass parameters>");
}
@@ -91,6 +92,15 @@ public class Main {
Method m = clazz.getDeclaredMethod("main", new Class[]{args.getClass()});
String[] args2 = new String[args.length-1];
System.arraycopy(args, 1, args2, 0, args2.length);
- m.invoke(null, (Object)args2);
+ try {
+ m.invoke(null, (Object)args2);
+ } catch (InvocationTargetException ite) {
+ Throwable cause = ite.getCause();
+ if (cause != null) {
+ throw cause;
+ } else {
+ throw ite;
+ }
+ }
}
}