瀏覽代碼

Added/Fixed error logging

Added error logging to VaultStats and GeneralPreferencesController
Fixed possible missing error logging in VaultService
JaniruTEC 4 年之前
父節點
當前提交
9c22adc97d

+ 1 - 0
main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java

@@ -36,6 +36,7 @@ public class VaultStats {
 		this.updateService = new UpdateStatsService();
 		updateService.setExecutor(executor);
 		updateService.setPeriod(Duration.seconds(1));
+		updateService.setOnFailed(event -> LOG.error("Error in UpdateStateService.", event.getSource().getException()));
 
 		state.addListener(this::vaultStateChanged);
 	}

+ 2 - 1
main/ui/src/main/java/org/cryptomator/ui/common/VaultService.java

@@ -69,7 +69,6 @@ public class VaultService {
 	public Task<Vault> createLockTask(Vault vault, boolean forced) {
 		Task<Vault> task = new LockVaultTask(vault, forced);
 		task.setOnSucceeded(evt -> LOG.info("Locked {}", vault.getDisplayName()));
-		task.setOnFailed(evt -> LOG.error("Failed to lock " + vault.getDisplayName(), evt.getSource().getException()));
 		return task;
 	}
 
@@ -165,6 +164,8 @@ public class VaultService {
 		public LockVaultTask(Vault vault, boolean forced) {
 			this.vault = vault;
 			this.forced = forced;
+
+			setOnFailed(event -> LOG.error("Failed to lock " + vault.getDisplayName(), event.getSource().getException()));
 		}
 
 		@Override

+ 4 - 1
main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java

@@ -109,7 +109,10 @@ public class GeneralPreferencesController implements FxController {
 		autoStartStrategy.ifPresent(autoStart -> {
 			boolean enableAutoStart = autoStartCheckbox.isSelected();
 			Task<Void> toggleTask = new ToggleAutoStartTask(autoStart, enableAutoStart);
-			toggleTask.setOnFailed(evt -> autoStartCheckbox.setSelected(!enableAutoStart)); // restore previous state
+			toggleTask.setOnFailed(event -> {
+				autoStartCheckbox.setSelected(!enableAutoStart); // restore previous state
+				LOG.error("Failed to toggle autostart.", event.getSource().getException());
+			});
 			executor.execute(toggleTask);
 		});
 	}