Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
albertus82 committed May 21, 2024
1 parent c0138be commit 0de2546
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import io.github.albertus82.jface.Events;
import io.github.albertus82.jface.Multilanguage;
import io.github.albertus82.jface.SwtUtils;
import io.github.albertus82.jface.closeable.CloseableDevice;
import io.github.albertus82.jface.preference.IPreferencesConfiguration;
import io.github.albertus82.util.InitializationException;
import lombok.AccessLevel;
Expand Down Expand Up @@ -116,30 +115,28 @@ public static void main(final String... args) {
}

private static void start() {
try (final CloseableDevice<Display> cd = new CloseableDevice<>(Display.getDefault())) {
Shell shell = null;
try {
EarthquakeBulletinConfig.initialize(); // Load configuration and initialize the application
final EarthquakeBulletinGui gui = new EarthquakeBulletinGui();
gui.open(); // Open main window
shell = gui.getShell();
loop(shell);
Shell shell = null;
try {
EarthquakeBulletinConfig.initialize(); // Load configuration and initialize the application
final EarthquakeBulletinGui gui = new EarthquakeBulletinGui();
gui.open(); // Open main window
shell = gui.getShell();
loop(shell);
}
catch (final InitializationException e) {
EnhancedErrorDialog.openError(shell, getApplicationName(), Messages.get("error.fatal.init"), IStatus.ERROR, e, Images.getAppIconArray());
throw e;
}
catch (final RuntimeException e) {
if (shell != null && shell.isDisposed()) {
log.debug("An unrecoverable error has occurred:", e);
// Do not rethrow, exiting with status OK.
}
catch (final InitializationException e) {
EnhancedErrorDialog.openError(shell, getApplicationName(), Messages.get("error.fatal.init"), IStatus.ERROR, e, Images.getAppIconArray());
else {
EnhancedErrorDialog.openError(shell, getApplicationName(), Messages.get("error.fatal"), IStatus.ERROR, e, Images.getAppIconArray());
throw e;
}
catch (final RuntimeException e) {
if (shell != null && shell.isDisposed()) {
log.debug("An unrecoverable error has occurred:", e);
// Do not rethrow, exiting with status OK.
}
else {
EnhancedErrorDialog.openError(shell, getApplicationName(), Messages.get("error.fatal"), IStatus.ERROR, e, Images.getAppIconArray());
throw e;
}
}
} // Display is disposed before the catch!
}
}

private static void loop(@NonNull final Shell shell) {
Expand Down

0 comments on commit 0de2546

Please sign in to comment.