remove single node root
[jalview.git] / forester / java / src / org / forester / util / ForesterUtil.java
index 1ca9ba2..cb04e65 100644 (file)
@@ -305,6 +305,13 @@ public final class ForesterUtil {
         }
     }
 
+    public static void fatalError( final String message ) {
+        System.err.println();
+        System.err.println( "error: " + message );
+        System.err.println();
+        System.exit( -1 );
+    }
+
     public static void fatalError( final String prg_name, final String message ) {
         System.err.println();
         System.err.println( "[" + prg_name + "] > " + message );
@@ -312,6 +319,16 @@ public final class ForesterUtil {
         System.exit( -1 );
     }
 
+    public static void fatalErrorIfFileNotReadable( final File file ) {
+        final String error = isReadableFile( file );
+        if ( !isEmpty( error ) ) {
+            System.err.println();
+            System.err.println( "error: " + error );
+            System.err.println();
+            System.exit( -1 );
+        }
+    }
+
     public static void fatalErrorIfFileNotReadable( final String prg_name, final File file ) {
         final String error = isReadableFile( file );
         if ( !isEmpty( error ) ) {
@@ -914,10 +931,34 @@ public final class ForesterUtil {
         return str_array;
     }
 
+    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();
+        System.exit( -1 );
+    }
+
+    final public static void unexpectedFatalError( final String message ) {
+        System.err.println();
+        System.err.println( "unexpected error: should not have occured! Please contact program author(s)." );
+        System.err.println( message );
+        System.err.println();
+        System.exit( -1 );
+    }
+
     final public static void unexpectedFatalError( final String prg_name, final Exception e ) {
         System.err.println();
         System.err.println( "[" + prg_name
-                + "] > Unexpected error. Should not have occured! Please contact program author(s)." );
+                + "] > unexpected error; should not have occured! Please contact program author(s)." );
         e.printStackTrace( System.err );
         System.err.println();
         System.exit( -1 );
@@ -926,7 +967,7 @@ public final class ForesterUtil {
     final public static void unexpectedFatalError( final String prg_name, final String message ) {
         System.err.println();
         System.err.println( "[" + prg_name
-                + "] > Unexpected error. Should not have occured! Please contact program author(s)." );
+                + "] > unexpected error: should not have occured! Please contact program author(s)." );
         System.err.println( message );
         System.err.println();
         System.exit( -1 );
@@ -935,7 +976,7 @@ public final class ForesterUtil {
     final public static void unexpectedFatalError( final String prg_name, final String message, final Exception e ) {
         System.err.println();
         System.err.println( "[" + prg_name
-                + "] > Unexpected error. Should not have occured! Please contact program author(s)." );
+                + "] > unexpected error: should not have occured! Please contact program author(s)." );
         System.err.println( message );
         e.printStackTrace( System.err );
         System.err.println();
@@ -946,7 +987,7 @@ public final class ForesterUtil {
         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++ ) {
@@ -1021,4 +1062,13 @@ public final class ForesterUtil {
         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 );
+    }
 }