diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-05-17 14:07:52 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-05-17 14:07:52 +0300 |
commit | 2fe83738e7fc920b8df3c9a92b6fd95b73ea7256 (patch) | |
tree | 3cb9f73448c4270b996cb77c13b2fc205730f0a0 /app | |
parent | 692160767de710f1a8fe2bee4981056c2f831cc3 (diff) | |
parent | f8b78df01b11b4230b8f6f93c096379ea9f5991c (diff) |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java | 15 | ||||
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/exceptions/ServerAppVersionNotParsableException.java | 14 |
2 files changed, 22 insertions, 7 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java b/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java index 9a8bfc05a..0710eba54 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java @@ -341,22 +341,25 @@ public class JsonToEntityParser { if (deck.has("version")) { version = deck.get("version").getAsString(); if (version == null || version.trim().length() < 1) { - throw new ServerAppVersionNotParsableException("capabilities endpoint returned an invalid version string: \"" + version + "\""); + throw new ServerAppVersionNotParsableException(ServerAppVersionNotParsableException.Hint.CAPABILITIES_VERSION_NOT_PARSABLE, + "capabilities endpoint returned an invalid version string: \"" + version + "\""); } } else { - throw new ServerAppVersionNotParsableException("deck version node is missing in capabilities endpoint! deck-node: "+deck.getAsString()); + throw new ServerAppVersionNotParsableException(ServerAppVersionNotParsableException.Hint.CAPABILITIES_VERSION_NOT_PARSABLE, + "deck version node is missing in capabilities endpoint! deck-node: "+deck.getAsString()); } } else { - throw new ServerAppVersionNotParsableException("deck node is missing in capabilities endpoint!"); + throw new ServerAppVersionNotParsableException(ServerAppVersionNotParsableException.Hint.CAPABILITIES_NOT_PARSABLE, + "deck node is missing in capabilities endpoint!"); } if (caps.has("theming")) { JsonObject theming = caps.getAsJsonObject("theming"); capabilities.setColor(theming.get("color").getAsString()); capabilities.setTextColor(theming.get("color-text").getAsString()); } - } - if (version == null || version.trim().length() < 1) { - throw new ServerAppVersionNotParsableException("capabilities endpoint returned no version string at all!"); + } else { + throw new ServerAppVersionNotParsableException(ServerAppVersionNotParsableException.Hint.CAPABILITIES_NOT_PARSABLE, + "capabilities node is missing in capabilities endpoint!"); } capabilities.setDeckVersion(Version.of(version)); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/ServerAppVersionNotParsableException.java b/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/ServerAppVersionNotParsableException.java index 25665bebb..e2521195b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/ServerAppVersionNotParsableException.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/ServerAppVersionNotParsableException.java @@ -2,7 +2,19 @@ package it.niedermann.nextcloud.deck.exceptions; public class ServerAppVersionNotParsableException extends IllegalArgumentException { - public ServerAppVersionNotParsableException(String message) { + public enum Hint { + CAPABILITIES_NOT_PARSABLE, + CAPABILITIES_VERSION_NOT_PARSABLE, + } + + private Hint hint; + + public ServerAppVersionNotParsableException(Hint hint, String message) { super(message); + this.hint = hint; + } + + public Hint getHint() { + return hint; } } |