Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordesperateCoder <echotodevnull@gmail.com>2022-01-08 20:08:08 +0300
committerdesperateCoder <echotodevnull@gmail.com>2022-01-08 20:08:08 +0300
commit1799ae95a02680b9fbf8bb65c5233c2795a71c14 (patch)
tree417d000d98724aeaa70a754f27f382508204068a /app/src/main/java/it/niedermann/nextcloud/deck/exceptions
parent1dcabdb46ca28ff8b5a6035ecbcf3f4882c63c99 (diff)
#1169 try to better handle networking errors
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/exceptions')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/exceptions/OfflineException.java40
1 files changed, 39 insertions, 1 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/OfflineException.java b/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/OfflineException.java
index c63b801a0..bcd41cb16 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/OfflineException.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/exceptions/OfflineException.java
@@ -1,7 +1,45 @@
package it.niedermann.nextcloud.deck.exceptions;
+import androidx.annotation.Nullable;
+
public class OfflineException extends IllegalStateException {
+
+ private final Reason reason;
+
+ public enum Reason {
+ OFFLINE("offline", "The device is currently offline"),
+ CONNECTION_REFUSED("connection_refused", "Connection was refused, please check if your server is reachable"),
+ CONNECTION_TIMEOUT("connection_timeout", "Connection timed out, please check if you're connected to the internet"),
+ ;
+
+ private String key;
+ private String whatHappened;
+
+ Reason(String key, String whatHappened) {
+ this.key = key;
+ this.whatHappened = whatHappened;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getWhatHappened() {
+ return whatHappened;
+ }
+ }
+
+
public OfflineException() {
- super("Device is currently offline.");
+ this(Reason.OFFLINE);
+ }
+ public OfflineException(Reason reason) {
+ super(reason.getWhatHappened());
+ this.reason = reason;
+ }
+
+ @Nullable
+ public Reason getReason() {
+ return reason;
}
}