Issue#41 Improved SibaCLI

This commit is contained in:
Didier Clermonté 2016-08-06 23:07:42 +02:00
parent 4ee42dc6c4
commit 1df0f7b4cf
1 changed files with 25 additions and 24 deletions

View File

@ -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);
}
});
}
}