mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-19 00:56:52 -04:00
Renamed exceptions
See: https://github.com/cryptomator/cryptomator/pull/3001#discussion_r1263563166
This commit is contained in:
@@ -2,11 +2,11 @@ package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class HideawayAlreadyExistsException extends IllegalMountPointException {
|
||||
public class ExistingHideawayException extends IllegalMountPointException {
|
||||
|
||||
private final Path hideaway;
|
||||
|
||||
public HideawayAlreadyExistsException(Path path, Path hideaway, String msg) {
|
||||
public ExistingHideawayException(Path path, Path hideaway, String msg) {
|
||||
super(path, msg);
|
||||
this.hideaway = hideaway;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MountPointCleanupFailedException extends IllegalMountPointException {
|
||||
|
||||
public MountPointCleanupFailedException(Path path) {
|
||||
super(path, "Mountpoint could not be cleared: " + path.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MountPointCouldNotBeClearedException extends IllegalMountPointException {
|
||||
|
||||
public MountPointCouldNotBeClearedException(Path path) {
|
||||
super(path, "Mountpoint could not be cleared: " + path.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MountPointNotExistingException extends IllegalMountPointException {
|
||||
|
||||
public MountPointNotExistingException(Path path, String msg) {
|
||||
super(path, msg);
|
||||
}
|
||||
|
||||
public MountPointNotExistingException(Path path) {
|
||||
super(path, "Mountpoint does not exist: " + path);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MountPointNotExistsException extends IllegalMountPointException {
|
||||
|
||||
public MountPointNotExistsException(Path path, String msg) {
|
||||
super(path, msg);
|
||||
}
|
||||
|
||||
public MountPointNotExistsException(Path path) {
|
||||
super(path, "Mountpoint does not exist: " + path);
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@ public final class MountWithinParentUtil {
|
||||
|
||||
//TODO: possible improvement by just deleting an _empty_ hideaway
|
||||
if (mpExists && hideExists) { //both resources exist (whatever type)
|
||||
throw new HideawayAlreadyExistsException(mountPoint, hideaway, "Hideaway (" + hideaway + ") already exists for mountpoint: " + mountPoint);
|
||||
throw new ExistingHideawayException(mountPoint, hideaway, "Hideaway (" + hideaway + ") already exists for mountpoint: " + mountPoint);
|
||||
} else if (!mpExists && !hideExists) { //neither mountpoint nor hideaway exist
|
||||
throw new MountPointNotExistsException(mountPoint);
|
||||
throw new MountPointNotExistingException(mountPoint);
|
||||
} else if (!mpExists) { //only hideaway exists
|
||||
checkIsDirectory(hideaway);
|
||||
LOG.info("Mountpoint {} seems to be not properly cleaned up. Will be fixed on unmount.", mountPoint);
|
||||
@@ -51,7 +51,7 @@ public final class MountWithinParentUtil {
|
||||
int attempts = 0;
|
||||
while (!Files.notExists(mountPoint)) {
|
||||
if (attempts >= 10) {
|
||||
throw new MountPointCouldNotBeClearedException(mountPoint);
|
||||
throw new MountPointCleanupFailedException(mountPoint);
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
attempts++;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class Mounter {
|
||||
throw new MountPointNotSupportedException(userChosenMountPoint, e.getMessage());
|
||||
} else if (canMountToDir && !canMountToParent && !Files.exists(userChosenMountPoint)) {
|
||||
//mountpoint must exist
|
||||
throw new MountPointNotExistsException(userChosenMountPoint, e.getMessage());
|
||||
throw new MountPointNotExistingException(userChosenMountPoint, e.getMessage());
|
||||
} else {
|
||||
//TODO: add specific exception for !canMountToDir && canMountToParent && !Files.notExists(userChosenMountPoint)
|
||||
throw new IllegalMountPointException(userChosenMountPoint, e.getMessage());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.cryptomator.ui.unlock;
|
||||
|
||||
import org.cryptomator.common.mount.HideawayAlreadyExistsException;
|
||||
import org.cryptomator.common.mount.ExistingHideawayException;
|
||||
import org.cryptomator.common.mount.IllegalMountPointException;
|
||||
import org.cryptomator.common.mount.MountPointCouldNotBeClearedException;
|
||||
import org.cryptomator.common.mount.MountPointCleanupFailedException;
|
||||
import org.cryptomator.common.mount.MountPointInUseException;
|
||||
import org.cryptomator.common.mount.MountPointNotEmptyDirectoryException;
|
||||
import org.cryptomator.common.mount.MountPointNotExistsException;
|
||||
import org.cryptomator.common.mount.MountPointNotExistingException;
|
||||
import org.cryptomator.common.mount.MountPointNotSupportedException;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
@@ -48,7 +48,7 @@ public class UnlockInvalidMountPointController implements FxController {
|
||||
this.exceptionType = getExceptionType(exc);
|
||||
this.exceptionPath = exc.getMountpoint();
|
||||
this.exceptionMessage = exc.getMessage();
|
||||
this.hideawayPath = exc instanceof HideawayAlreadyExistsException haeExc ? haeExc.getHideaway() : null;
|
||||
this.hideawayPath = exc instanceof ExistingHideawayException haeExc ? haeExc.getHideaway() : null;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -79,10 +79,10 @@ public class UnlockInvalidMountPointController implements FxController {
|
||||
private ExceptionType getExceptionType(Throwable unlockException) {
|
||||
return switch (unlockException) {
|
||||
case MountPointNotSupportedException x -> ExceptionType.NOT_SUPPORTED;
|
||||
case MountPointNotExistsException x -> ExceptionType.NOT_EXISTING;
|
||||
case MountPointNotExistingException x -> ExceptionType.NOT_EXISTING;
|
||||
case MountPointInUseException x -> ExceptionType.IN_USE;
|
||||
case HideawayAlreadyExistsException x -> ExceptionType.HIDEAWAY_EXISTS;
|
||||
case MountPointCouldNotBeClearedException x -> ExceptionType.COULD_NOT_BE_CLEARED;
|
||||
case ExistingHideawayException x -> ExceptionType.HIDEAWAY_EXISTS;
|
||||
case MountPointCleanupFailedException x -> ExceptionType.COULD_NOT_BE_CLEARED;
|
||||
case MountPointNotEmptyDirectoryException x -> ExceptionType.NOT_EMPTY_DIRECTORY;
|
||||
default -> ExceptionType.GENERIC;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user