From 63831387cf92f3d290e942a744949be1df5bc285 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 12 Aug 2015 13:39:33 -0700 Subject: [PATCH] Only catch exceptions originating from incorrect use in preloader --- .../kotlin/preloading/Preloader.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/compiler/preloader/src/org/jetbrains/kotlin/preloading/Preloader.java b/compiler/preloader/src/org/jetbrains/kotlin/preloading/Preloader.java index d22fbb68be1..9381bcb1ad3 100644 --- a/compiler/preloader/src/org/jetbrains/kotlin/preloading/Preloader.java +++ b/compiler/preloader/src/org/jetbrains/kotlin/preloading/Preloader.java @@ -34,9 +34,8 @@ public class Preloader { try { run(args); } - catch (Throwable e) { + catch (PreloaderException e) { System.err.println("error: " + e.toString()); - e.printStackTrace(); System.err.println(); printUsage(System.err); System.exit(1); @@ -112,15 +111,15 @@ public class Preloader { System.exit(0); } else if ("-cp".equals(arg) || "-classpath".equals(arg)) { - if (end) throw new RuntimeException("no argument provided to " + arg); + if (end) throw new PreloaderException("no argument provided to " + arg); classpath = parseClassPath(args[++i]); } else if ("-estimate".equals(arg)) { - if (end) throw new RuntimeException("no argument provided to " + arg); + if (end) throw new PreloaderException("no argument provided to " + arg); estimate = Integer.parseInt(args[++i]); } else if ("-instrument".equals(arg)) { - if (end) throw new RuntimeException("no argument provided to " + arg); + if (end) throw new PreloaderException("no argument provided to " + arg); instrumenters = parseClassPath(args[++i]); } else if ("-measure".equals(arg)) { @@ -133,7 +132,7 @@ public class Preloader { } } - if (mainClass == null) throw new RuntimeException("no main class name provided"); + if (mainClass == null) throw new PreloaderException("no main class name provided"); return new Options(classpath, measure, instrumenters, estimate, mainClass, arguments); } @@ -152,7 +151,7 @@ public class Preloader { for (String path : paths) { File file = new File(path); if (!file.exists()) { - throw new RuntimeException("file does not exist: " + file); + throw new PreloaderException("file does not exist: " + file); } files.add(file); } @@ -242,6 +241,12 @@ public class Preloader { } } + private static class PreloaderException extends RuntimeException { + public PreloaderException(String message) { + super(message); + } + } + private static class Handler extends ClassHandler { public void done() {} }