diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-06-15 01:13:07 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-06-15 01:24:46 -0400 |
commit | ebff3d51b990c8f8e292084dcd5f3a0342f83f37 (patch) | |
tree | 8274f1372eced85bcde38c39135fd73bde987ab2 /nailgun_launcher | |
parent | 2716491ed0f3b90d520f84900358638fbfacf912 (diff) | |
download | cbt-ebff3d51b990c8f8e292084dcd5f3a0342f83f37.tar.gz cbt-ebff3d51b990c8f8e292084dcd5f3a0342f83f37.tar.bz2 cbt-ebff3d51b990c8f8e292084dcd5f3a0342f83f37.zip |
unwrap InvocationTargetException. Any reason not to do this? Seems just easier to read without.
Diffstat (limited to 'nailgun_launcher')
-rw-r--r-- | nailgun_launcher/NailgunLauncher.java | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java index 1007343..c909c12 100644 --- a/nailgun_launcher/NailgunLauncher.java +++ b/nailgun_launcher/NailgunLauncher.java @@ -65,21 +65,35 @@ public class NailgunLauncher{ false, start, cache, CBT_HOME, compatibilityTarget, classLoaderCache ); - System.exit( - (Integer) res - .classLoader - .loadClass("cbt.Stage1") - .getMethod( - "run", - String[].class, File.class, File.class, Boolean.class, - File.class, Long.class, ConcurrentHashMap.class, ConcurrentHashMap.class - ) - .invoke( - null, - (Object) args, new File(cache), new File(CBT_HOME), res.changed, - new File(compatibilityTarget), start, classLoaderCache.keys, classLoaderCache.values - ) - ); + try{ + System.exit( + (Integer) res + .classLoader + .loadClass("cbt.Stage1") + .getMethod( + "run", + String[].class, File.class, File.class, Boolean.class, + File.class, Long.class, ConcurrentHashMap.class, ConcurrentHashMap.class + ) + .invoke( + null, + (Object) args, new File(cache), new File(CBT_HOME), res.changed, + new File(compatibilityTarget), start, classLoaderCache.keys, classLoaderCache.values + ) + ); + } catch (Exception e) { + Throwable t = unwrapInvocationTargetException(e); + t.printStackTrace(); + System.exit(1); + } + } + + public static Throwable unwrapInvocationTargetException(Throwable e){ + if(e instanceof java.lang.reflect.InvocationTargetException){ + return unwrapInvocationTargetException(((java.lang.reflect.InvocationTargetException) e).getCause()); + } else{ + return e; + } } public static BuildStage1Result buildStage1( |