From 1df0f7b4cf9787a4499a41ba70768c889412c217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clermont=C3=A9?= Date: Sat, 6 Aug 2016 23:07:42 +0200 Subject: [PATCH] Issue#41 Improved SibaCLI --- src/org/dclermonte/siba/cli/SibaCLI.java | 49 ++++++++++++------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/org/dclermonte/siba/cli/SibaCLI.java b/src/org/dclermonte/siba/cli/SibaCLI.java index a1597ed..102f986 100644 --- a/src/org/dclermonte/siba/cli/SibaCLI.java +++ b/src/org/dclermonte/siba/cli/SibaCLI.java @@ -38,30 +38,6 @@ public class SibaCLI private static final Logger logger = LoggerFactory.getLogger(SibaCLI.class); private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.cli.messages"); //$NON-NLS-1$ - public SibaCLI() - { - // Set default CLI catch. - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() - { - @Override - public void uncaughtException(final Thread thread, final Throwable exception) - { - String message; - if (exception instanceof OutOfMemoryError) - { - message = "Java ran out of memory!\n\n"; - } - else - { - message = "An error occured: " + exception.getClass() + "(" + exception.getMessage() + ")"; - } - - logger.error("uncaughtException ", exception); - logger.error(message); - } - }); - } - public static void backup(final File directoryToSave) throws SibaException { File result; @@ -129,6 +105,7 @@ public class SibaCLI */ public static void run(final String[] args) { + sibaCLIException(); try { // This part implements an automate. @@ -204,4 +181,28 @@ public class SibaCLI help(); } } + + public static void sibaCLIException() + { + // Set default CLI catch. + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() + { + @Override + public void uncaughtException(final Thread thread, final Throwable exception) + { + String message; + if (exception instanceof OutOfMemoryError) + { + message = "Java ran out of memory!\n\n"; + } + else + { + message = "An error occured: " + exception.getClass() + "(" + exception.getMessage() + ")"; + } + + logger.error("uncaughtException ", exception); + logger.error(message); + } + }); + } }