logging and unit test updates
[debian/openrocket] / src / net / sf / openrocket / gui / main / ExceptionHandler.java
index 8496ad5be57f6400d37d986a2f4764e54a999412..4099f019120d4c4942c5db5c1b795854ea96d29d 100644 (file)
@@ -103,14 +103,14 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
         * @param exception             the exception that occurred.
         */
        public static void handleErrorCondition(final Exception exception) {
-               final ExceptionHandler handler;
+               final ExceptionHandler handler = instance;
 
                try {
 
-                       if (instance == null) {
-                               handler = new ExceptionHandler();
-                       } else {
-                               handler = instance;
+                       if (handler == null) {
+                               // Not initialized, simply print the exception
+                               exception.printStackTrace();
+                               return;
                        }
 
                        final Thread thread = Thread.currentThread();
@@ -149,12 +149,18 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
                        return;
                }
                
+               // Create the message
+               String msg = e.getClass().getSimpleName() + ": " + e.getMessage();
+               if (msg.length() > 90) {
+                       msg = msg.substring(0, 80) + "...";
+               }
+               
                // Unknown Error
                if (!(e instanceof Exception)) {
                        JOptionPane.showMessageDialog(null, 
                                        new Object[] { 
                                                "An unknown Java error occurred:",
-                                               e.getMessage(),
+                                               msg,
                                                "<html>You should immediately close unnecessary design windows,<br>" +
                                                "save any unsaved designs and restart OpenRocket!"
                                        }, "Unknown Java error", JOptionPane.ERROR_MESSAGE);
@@ -162,13 +168,7 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
                }
                
                
-               // Normal exception, show question dialog
-               String msg = e.getClass().getSimpleName() + ": " + e.getMessage();
-               if (msg.length() > 90) {
-                       msg = msg.substring(0, 80) + "...";
-               }
-               
-               
+               // Normal exception, show question dialog               
                int selection = JOptionPane.showOptionDialog(null, new Object[] {
                                "OpenRocket encountered an uncaught exception.  This typically signifies " +
                                "a bug in the software.",