Issue#41 added default exception management in SibaCLI
This commit is contained in:
parent
060bfebbe6
commit
bedef25565
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user