From 6af016f1feb85ce63d21ebeed4d9be398b301ca5 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sat, 2 Apr 2022 11:51:34 +0200 Subject: [PATCH] log errors occuring in async "show window" tasks --- .../cryptomator/ui/fxapp/FxApplicationWindows.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java index 2fcf2718b..ba28f9bc4 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java @@ -97,15 +97,15 @@ public class FxApplicationWindows { } public CompletionStage showMainWindow() { - return CompletableFuture.supplyAsync(mainWindow.get()::showMainWindow, Platform::runLater); + return CompletableFuture.supplyAsync(mainWindow.get()::showMainWindow, Platform::runLater).whenComplete(this::reportErrors); } public CompletionStage showPreferencesWindow(SelectedPreferencesTab selectedTab) { - return CompletableFuture.supplyAsync(() -> preferencesWindow.get().showPreferencesWindow(selectedTab), Platform::runLater); + return CompletableFuture.supplyAsync(() -> preferencesWindow.get().showPreferencesWindow(selectedTab), Platform::runLater).whenComplete(this::reportErrors); } public CompletionStage showQuitWindow(QuitResponse response) { - return CompletableFuture.supplyAsync(() -> quitWindow.get().showQuitWindow(response), Platform::runLater); + return CompletableFuture.supplyAsync(() -> quitWindow.get().showQuitWindow(response), Platform::runLater).whenComplete(this::reportErrors); } public CompletionStage startUnlockWorkflow(Vault vault, @Nullable Stage owner) { @@ -143,7 +143,13 @@ public class FxApplicationWindows { * @return A */ public CompletionStage showErrorWindow(Throwable cause, Stage window, @Nullable Scene previousScene) { - return CompletableFuture.supplyAsync(() -> errorWindowFactory.create(cause, window, previousScene).show(), Platform::runLater); + return CompletableFuture.supplyAsync(() -> errorWindowFactory.create(cause, window, previousScene).show(), Platform::runLater).whenComplete(this::reportErrors); + } + + private void reportErrors(@Nullable Stage stage, @Nullable Throwable error) { + if (error != null) { + LOG.error("Failed to display stage", error); + } } }