From c3ac043c68d4add2c2ef687f34b541219cca81e2 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:13:11 +0200 Subject: [PATCH] Removed MountPointPreparationException See: https://github.com/cryptomator/cryptomator/pull/3001#discussion_r1263572178 --- .../mount/IllegalMountPointException.java | 2 -- .../mount/MountPointPreparationException.java | 18 ------------------ .../common/mount/MountWithinParentUtil.java | 9 +++++---- 3 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 src/main/java/org/cryptomator/common/mount/MountPointPreparationException.java diff --git a/src/main/java/org/cryptomator/common/mount/IllegalMountPointException.java b/src/main/java/org/cryptomator/common/mount/IllegalMountPointException.java index a96e4f0bb..30419d85c 100644 --- a/src/main/java/org/cryptomator/common/mount/IllegalMountPointException.java +++ b/src/main/java/org/cryptomator/common/mount/IllegalMountPointException.java @@ -5,8 +5,6 @@ import java.nio.file.Path; /** * Indicates that validation or preparation of a mountpoint failed due to a configuration error or an invalid system state.
* Instances of this exception are usually caught and displayed to the user in an appropriate fashion, e.g. by {@link org.cryptomator.ui.unlock.UnlockInvalidMountPointController UnlockInvalidMountPointController.} - * - * @see MountPointPreparationException MountPointPreparationException for wrapping exceptions which occur while preparing the mountpoint. */ public class IllegalMountPointException extends IllegalArgumentException { diff --git a/src/main/java/org/cryptomator/common/mount/MountPointPreparationException.java b/src/main/java/org/cryptomator/common/mount/MountPointPreparationException.java deleted file mode 100644 index 12a4a1c29..000000000 --- a/src/main/java/org/cryptomator/common/mount/MountPointPreparationException.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.cryptomator.common.mount; - -/** - * Used for wrapping exceptions which occur while preparing the mountpoint.
- * Instances of this exception are usually treated as generic error. - * - * @see IllegalMountPointException IllegalMountPointException for indicating configuration errors. - */ -public class MountPointPreparationException extends RuntimeException { - - public MountPointPreparationException(Throwable cause) { - super(cause); - } - - public MountPointPreparationException(String msg, Throwable cause) { - super(msg, cause); - } -} \ No newline at end of file diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index e7a703e43..64f382e02 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.LinkOption; @@ -19,7 +20,7 @@ public final class MountWithinParentUtil { private MountWithinParentUtil() {} - static void prepareParentNoMountPoint(Path mountPoint) throws IllegalMountPointException, MountPointPreparationException { + static void prepareParentNoMountPoint(Path mountPoint) throws IllegalMountPointException { Path hideaway = getHideaway(mountPoint); var mpExists = Files.exists(mountPoint, LinkOption.NOFOLLOW_LINKS); var hideExists = Files.exists(hideaway, LinkOption.NOFOLLOW_LINKS); @@ -37,7 +38,7 @@ public final class MountWithinParentUtil { Files.setAttribute(hideaway, WIN_HIDDEN_ATTR, true, LinkOption.NOFOLLOW_LINKS); } } catch (IOException e) { - throw new MountPointPreparationException(e); + throw new UncheckedIOException(e); } } else { //only mountpoint exists try { @@ -57,10 +58,10 @@ public final class MountWithinParentUtil { attempts++; } } catch (IOException e) { - throw new MountPointPreparationException(e); + throw new UncheckedIOException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new MountPointPreparationException(e); + throw new RuntimeException(e); } } }