changeset 12:9ac6136c710c

Replace the temporary error handling in Initialize.kt.
author David Barts <n5jrn@me.com>
date Fri, 10 Apr 2020 23:22:36 -0700
parents e52fd1a575de
children a59d84674fb0
files src/name/blackcap/exifwasher/exiv2/Initialize.kt
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/name/blackcap/exifwasher/exiv2/Initialize.kt	Fri Apr 10 20:58:03 2020 -0700
+++ b/src/name/blackcap/exifwasher/exiv2/Initialize.kt	Fri Apr 10 23:22:36 2020 -0700
@@ -8,7 +8,12 @@
 import java.io.IOException
 import java.util.jar.JarEntry
 import java.util.jar.JarFile
+import java.util.logging.Level
+import java.util.logging.Logger
+import javax.swing.*
+import name.blackcap.exifwasher.Application
 import name.blackcap.exifwasher.LF_DIR
+import name.blackcap.exifwasher.LOGGER
 import name.blackcap.exifwasher.OS
 
 object Initialize {
@@ -57,12 +62,14 @@
                     target.setLastModified(source.getTime())
                 }
             } catch (e: IOException) {
+                LOGGER.log(Level.SEVERE, "unable to create ${tPath}", e)
                 val message = e.message ?: "I/O error"
                 die("unable to create ${tPath}: ${message}")
             }
             try {
                 System.load(tPath)
             } catch (e: UnsatisfiedLinkError) {
+                LOGGER.log(Level.SEVERE, "unable to link ${tPath}", e)
                 val message = e.message ?: "unsatisfied link"
                 die("unable to link ${tPath}: ${message}")
             }
@@ -72,8 +79,10 @@
     }
 
     private fun die(message: String) {
-        /* should open a dialog */
-        System.err.println(message)
+        JOptionPane.showMessageDialog(Application.mainFrame,
+            "A fatal error occurred in initialization:\n${message}",
+            "Error", JOptionPane.ERROR_MESSAGE)
+        LOGGER.log(Level.SEVERE, "aborted due to fatal error")
         System.exit(1)
     }
 }