catch ( final IOException e ) {
fatalError( "error", e.toString(), log_writer );
}
+ catch ( final OutOfMemoryError e ) {
+ ForesterUtil.outOfMemoryError( e );
+ }
catch ( final Exception e ) {
e.printStackTrace();
fatalError( "unexpected error", e.toString(), log_writer );
catch ( final IOException e ) {
ForesterUtil.fatalError( e.getLocalizedMessage() );
}
+ catch ( final OutOfMemoryError e ) {
+ ForesterUtil.outOfMemoryError( e );
+ }
catch ( final Exception e ) {
ForesterUtil.unexpectedFatalError( e );
}
+ catch ( final Error e ) {
+ ForesterUtil.unexpectedFatalError( e );
+ }
time = System.currentTimeMillis() - time;
System.out.println( "Time: " + time + "ms" );
System.out.println( "OK" );
}
}
- final static void unexpectedError( final Error err ) {
- err.printStackTrace();
+ final static void unexpectedError( final Error e ) {
+ System.err.println();
+ e.printStackTrace( System.err );
+ System.err.println();
final StringBuffer sb = new StringBuffer();
- for( final StackTraceElement s : err.getStackTrace() ) {
+ for( final StackTraceElement s : e.getStackTrace() ) {
sb.append( s + "\n" );
}
JOptionPane
.showMessageDialog( null,
"An unexpected (possibly severe) error has occured - terminating. \nPlease contact: "
- + Constants.AUTHOR_EMAIL + " \nError: " + err + "\n" + sb,
+ + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n" + sb,
"Unexpected Severe Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
JOptionPane.ERROR_MESSAGE );
System.exit( -1 );
}
+
+ final static void outOfMemoryError( final OutOfMemoryError e ) {
+ System.err.println();
+ System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" );
+ System.err.println();
+ e.printStackTrace();
+ System.err.println();
+
+ JOptionPane
+ .showMessageDialog( null,
+ "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
+ + "\n\nError: " + e.getLocalizedMessage(),
+ "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
+ JOptionPane.ERROR_MESSAGE );
+ System.exit( -1 );
+ }
- final static void unexpectedException( final Exception ex ) {
- ex.printStackTrace();
+ final static void unexpectedException( final Exception e ) {
+ System.err.println();
+ e.printStackTrace( System.err );
+ System.err.println();
final StringBuffer sb = new StringBuffer();
- for( final StackTraceElement s : ex.getStackTrace() ) {
+ for( final StackTraceElement s : e.getStackTrace() ) {
sb.append( s + "\n" );
}
JOptionPane.showMessageDialog( null, "An unexpected exception has occured. \nPlease contact: "
- + Constants.AUTHOR_EMAIL + " \nException: " + ex + "\n" + sb, "Unexpected Exception ["
+ + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage() + "\n" + sb, "Unexpected Exception ["
+ Constants.PRG_NAME + Constants.VERSION + "]", JOptionPane.ERROR_MESSAGE );
}
try {
MainFrameApplication.createInstance( phylogenies, conf, title, current_dir );
}
- catch ( final Exception ex ) {
- AptxUtil.unexpectedException( ex );
+ catch ( final OutOfMemoryError e ) {
+ AptxUtil.outOfMemoryError( e );
}
- catch ( final Error err ) {
- AptxUtil.unexpectedError( err );
+ catch ( final Exception e ) {
+ AptxUtil.unexpectedException( e );
+ }
+ catch ( final Error e ) {
+ AptxUtil.unexpectedError( e );
}
}
}
\ No newline at end of file
catch ( final IllegalAccessException e ) {
AptxUtil.dieWithSystemError( "illegal access exception: " + e.toString() );
}
- catch ( final Exception e ) {
- AptxUtil.dieWithSystemError( e.toString() );
- }
+
if ( ( current_dir != null ) && current_dir.canRead() && current_dir.isDirectory() ) {
setCurrentDir( current_dir );
}
final public static void unexpectedFatalError( final Exception e ) {
System.err.println();
+ System.err.println( "unexpected exception: should not have occured! Please contact program author(s)." );
+ e.printStackTrace( System.err );
+ System.err.println();
+ System.exit( -1 );
+ }
+
+ final public static void unexpectedFatalError( final Error e ) {
+ System.err.println();
System.err.println( "unexpected error: should not have occured! Please contact program author(s)." );
e.printStackTrace( System.err );
System.err.println();
final int width = 50;
System.out.print( "\r[" );
int i = 0;
- for( ; i <= ( int ) ( progress_percentage * width ); i++ ) {
+ for( ; i <= ForesterUtil.roundToInt( progress_percentage * width ); i++ ) {
System.out.print( "." );
}
for( ; i < width; i++ ) {
final String regex = "[\\s;,]+";
return str.split( regex );
}
+
+ public final static void outOfMemoryError( final OutOfMemoryError e ) {
+ System.err.println();
+ System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" );
+ System.err.println();
+ e.printStackTrace( System.err );
+ System.err.println();
+ System.exit( -1 );
+ }
}