From 287789be53166cac1d1f247b07bdfdbb617042ef Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 21 Aug 2015 11:05:31 -0400 Subject: [PATCH] Use StartupError to format all exceptions hitting the console --- .../java/org/elasticsearch/bootstrap/Bootstrap.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index b871b4eb0b1..a96de5ef696 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -221,8 +221,17 @@ public class Bootstrap { keepAliveLatch.countDown(); } } + + /** Calls doMain(), but with special formatting of errors */ + public static void main(String[] args) throws StartupError { + try { + doMain(args); + } catch (Throwable t) { + throw new StartupError(t); + } + } - public static void main(String[] args) throws Throwable { + public static void doMain(String[] args) throws Throwable { BootstrapCLIParser bootstrapCLIParser = new BootstrapCLIParser(); CliTool.ExitStatus status = bootstrapCLIParser.execute(args); @@ -291,7 +300,7 @@ public class Bootstrap { Loggers.enableConsoleLogging(); } - throw new StartupError(e); + throw e; } }