JaniruTEC 2021-06-25 00:17:17 +02:00
parent 3762441230
commit 714a0c6664
3 changed files with 21 additions and 33 deletions

View File

@ -1,23 +0,0 @@
package org.cryptomator.common.settings;
import java.net.URI;
public interface AbstractInvalidSetting {
/**
* Returns the corresponding issue URI of this setting.<br>
* The issue URI usually resolves to a page on the
* <a href="https://github.com/cryptomator/cryptomator/issues">Cryptomator Bugtracker.</a>
*
* @return the issue URI or {@code null} if none is provided.
*/
URI getIssueURI();
/**
* Returns a (preferably localized) message, that helps the user understand the
* issue in their configuration and how to fix it.
*
* @return the non-null description of the issue.
*/
String getMessage();
}

View File

@ -4,7 +4,7 @@ import java.net.URI;
import java.util.Objects;
import java.util.ResourceBundle;
public enum InvalidSetting implements AbstractInvalidSetting {
public enum InvalidSetting {
;
@ -24,12 +24,23 @@ public enum InvalidSetting implements AbstractInvalidSetting {
this(onDefaultTracker(issueId), Objects.requireNonNull(resourceKey));
}
@Override
/**
* Returns the corresponding issue URI of this setting.<br>
* The issue URI usually resolves to a page on the
* <a href="https://github.com/cryptomator/cryptomator/issues">Cryptomator Bugtracker.</a>
*
* @return the issue URI or {@code null} if none is provided.
*/
public URI getIssueURI() {
return this.issue;
}
@Override
/**
* Returns a (preferably localized) message, that helps the user understand the
* issue in their configuration and how to fix it.
*
* @return the non-null description of the issue.
*/
public String getMessage() {
if (!BUNDLE.containsKey(this.resourceKey)) {
return UNKNOWN_KEY_FORMAT.formatted(this.resourceKey);

View File

@ -3,28 +3,28 @@ package org.cryptomator.common.settings;
public class InvalidSettingException extends RuntimeException {
private final AbstractInvalidSetting reason;
private final InvalidSetting reason;
private final String additionalMessage;
public InvalidSettingException(AbstractInvalidSetting reason) {
public InvalidSettingException(InvalidSetting reason) {
this(reason, null, null);
}
public InvalidSettingException(AbstractInvalidSetting reason, String additionalMessage) {
public InvalidSettingException(InvalidSetting reason, String additionalMessage) {
this(reason, additionalMessage, null);
}
public InvalidSettingException(AbstractInvalidSetting reason, Throwable cause) {
public InvalidSettingException(InvalidSetting reason, Throwable cause) {
this(reason, null, cause);
}
public InvalidSettingException(AbstractInvalidSetting reason, String additionalMessage, Throwable cause) {
public InvalidSettingException(InvalidSetting reason, String additionalMessage, Throwable cause) {
super(composeMessage(reason, additionalMessage), cause);
this.reason = reason;
this.additionalMessage = additionalMessage;
}
public AbstractInvalidSetting getReason() {
public InvalidSetting getReason() {
return this.reason;
}
@ -32,7 +32,7 @@ public class InvalidSettingException extends RuntimeException {
return this.additionalMessage;
}
private static String composeMessage(AbstractInvalidSetting reason, String additionalMessage) {
private static String composeMessage(InvalidSetting reason, String additionalMessage) {
if (additionalMessage == null) {
return reason.getMessage();
}