Mercurial > cgi-bin > hgweb.cgi > JpegWasher
comparison src/name/blackcap/exifwasher/exiv2/Initialize.kt @ 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 | efd9fe2d70d7 |
children | cd2ca4727b7f |
comparison
equal
deleted
inserted
replaced
11:e52fd1a575de | 12:9ac6136c710c |
---|---|
6 import java.io.File | 6 import java.io.File |
7 import java.io.FileOutputStream | 7 import java.io.FileOutputStream |
8 import java.io.IOException | 8 import java.io.IOException |
9 import java.util.jar.JarEntry | 9 import java.util.jar.JarEntry |
10 import java.util.jar.JarFile | 10 import java.util.jar.JarFile |
11 import java.util.logging.Level | |
12 import java.util.logging.Logger | |
13 import javax.swing.* | |
14 import name.blackcap.exifwasher.Application | |
11 import name.blackcap.exifwasher.LF_DIR | 15 import name.blackcap.exifwasher.LF_DIR |
16 import name.blackcap.exifwasher.LOGGER | |
12 import name.blackcap.exifwasher.OS | 17 import name.blackcap.exifwasher.OS |
13 | 18 |
14 object Initialize { | 19 object Initialize { |
15 private var initialized = false | 20 private var initialized = false |
16 | 21 |
55 } | 60 } |
56 target.setExecutable(true) | 61 target.setExecutable(true) |
57 target.setLastModified(source.getTime()) | 62 target.setLastModified(source.getTime()) |
58 } | 63 } |
59 } catch (e: IOException) { | 64 } catch (e: IOException) { |
65 LOGGER.log(Level.SEVERE, "unable to create ${tPath}", e) | |
60 val message = e.message ?: "I/O error" | 66 val message = e.message ?: "I/O error" |
61 die("unable to create ${tPath}: ${message}") | 67 die("unable to create ${tPath}: ${message}") |
62 } | 68 } |
63 try { | 69 try { |
64 System.load(tPath) | 70 System.load(tPath) |
65 } catch (e: UnsatisfiedLinkError) { | 71 } catch (e: UnsatisfiedLinkError) { |
72 LOGGER.log(Level.SEVERE, "unable to link ${tPath}", e) | |
66 val message = e.message ?: "unsatisfied link" | 73 val message = e.message ?: "unsatisfied link" |
67 die("unable to link ${tPath}: ${message}") | 74 die("unable to link ${tPath}: ${message}") |
68 } | 75 } |
69 } | 76 } |
70 | 77 |
71 initialized = true | 78 initialized = true |
72 } | 79 } |
73 | 80 |
74 private fun die(message: String) { | 81 private fun die(message: String) { |
75 /* should open a dialog */ | 82 JOptionPane.showMessageDialog(Application.mainFrame, |
76 System.err.println(message) | 83 "A fatal error occurred in initialization:\n${message}", |
84 "Error", JOptionPane.ERROR_MESSAGE) | |
85 LOGGER.log(Level.SEVERE, "aborted due to fatal error") | |
77 System.exit(1) | 86 System.exit(1) |
78 } | 87 } |
79 } | 88 } |