diff --git a/src/org/dclermonte/siba/cli/SibaCLI.java b/src/org/dclermonte/siba/cli/SibaCLI.java index 6bcbed0..a1597ed 100644 --- a/src/org/dclermonte/siba/cli/SibaCLI.java +++ b/src/org/dclermonte/siba/cli/SibaCLI.java @@ -38,6 +38,30 @@ 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;