blob: 946f7b049295349ee049dd2fd0cf888a25daac59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package it.niedermann.nextcloud.deck.exceptions;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import it.niedermann.nextcloud.deck.R;
public class OfflineException extends IllegalStateException {
private final Reason reason;
public OfflineException() {
this(Reason.OFFLINE);
}
public OfflineException(@NonNull Reason reason) {
super(reason.getKey());
this.reason = reason;
}
@NonNull
public Reason getReason() {
return reason;
}
public enum Reason {
OFFLINE("Device is currently offline", R.string.error_dialog_tip_offline_no_internet),
CONNECTION_REFUSED("Connection refused", R.string.error_dialog_tip_offline_connection_refused),
CONNECTION_TIMEOUT("Connection timeout", R.string.error_dialog_tip_offline_connection_timeout),
CONNECTION_REJECTED("Connection rejected", R.string.error_dialog_tip_connection_rejected),
;
private final String key;
@StringRes
private final int message;
Reason(@NonNull String key, @StringRes int message) {
this.key = key;
this.message = message;
}
public String getKey() {
return key;
}
@StringRes
public int getMessage() {
return message;
}
}
}
|