Issue#41 Improved SibaCLI
This commit is contained in:
parent
4ee42dc6c4
commit
1df0f7b4cf
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user