From d0683fa0ee4a8f6f65370f900cf592156ac2ff6f Mon Sep 17 00:00:00 2001
From: Richard Cordovano <rcordovano@basistech.com>
Date: Sat, 30 Jan 2016 15:01:26 -0500
Subject: [PATCH] Improve Core Installer error handling

---
 .../autopsy/corecomponents/Installer.java     | 28 +++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java
index ce1fceda24..9121ad4d23 100644
--- a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java
+++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java
@@ -83,14 +83,14 @@ public void restored() {
                             try {
                                 Case.open(caseFile);
                             } catch (Exception ex) {
-                                logger.log(Level.SEVERE, "Error opening case", ex); //NON-NLS
+                                logger.log(Level.SEVERE, String.format("Error opening case with metadata file path %s", caseFile), ex); //NON-NLS
                             }
                         }).start();
                         return;
                     }
                 }
             }
-            Case.invokeStartupDialog(); // bring up the startup dialog
+            Case.invokeStartupDialog();
         });
 
     }
@@ -103,12 +103,19 @@ public void uninstalled() {
     @Override
     public void close() {
         new Thread(() -> {
+            String caseDirName = null;
             try {
                 if (Case.isCaseOpen()) {
-                    Case.getCurrentCase().closeCase();
+                    Case currentCase = Case.getCurrentCase();
+                    caseDirName = currentCase.getCaseDirectory();
+                    currentCase.closeCase();
                 }
-            } catch (CaseActionException | IllegalStateException ex) {
-                logger.log(Level.SEVERE, "Error closing case", ex); //NON-NLS
+            } catch (CaseActionException ex) {
+                logger.log(Level.SEVERE, String.format("Error closing case with case directory %s", (null != caseDirName ? caseDirName : "?")), ex); //NON-NLS
+            } catch (IllegalStateException ignored) {
+                /*
+                 * No current case. Case.isCaseOpen is not reliable. 
+                 */
             }
         }).start();
     }
@@ -128,7 +135,7 @@ private void setOSXLookAndFeel() {
         try {
             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
-            logger.log(Level.WARNING, "Unable to set theme. ", ex); //NON-NLS
+            logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
         }
 
         // Store the keys that deal with menu items
@@ -138,20 +145,19 @@ private void setOSXLookAndFeel() {
             uiEntries.put(key, UIManager.get(key));
         }
 
-        // Use Metal if available
+        // Use Metal if available.
         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
             if ("Nimbus".equals(info.getName())) { //NON-NLS
                 try {
                     UIManager.setLookAndFeel(info.getClassName());
-                } catch (ClassNotFoundException | InstantiationException |
-                        IllegalAccessException | UnsupportedLookAndFeelException ex) {
-                    logger.log(Level.WARNING, "Unable to set theme. ", ex); //NON-NLS
+                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
+                    logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
                 }
                 break;
             }
         }
 
-        // Overwrite the Metal menu item keys to use the Aqua versions
+        // Overwrite the Metal menu item keys to use the Aqua versions.
         uiEntries.entrySet().stream().forEach((entry) -> {
             UIManager.put(entry.getKey(), entry.getValue());
         });
-- 
GitLab