aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java')
-rw-r--r--app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java49
1 files changed, 0 insertions, 49 deletions
diff --git a/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java b/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
index 3cb5ca9f..5188112c 100644
--- a/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
+++ b/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
@@ -5,17 +5,9 @@
package com.wireguard.android.util;
-import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.util.Log;
-import com.wireguard.android.Application;
-import com.wireguard.android.R;
-import com.wireguard.config.BadConfigException;
-import com.wireguard.config.ParseException;
-import com.wireguard.crypto.KeyFormatException;
-
-import java9.util.concurrent.CompletionException;
import java9.util.function.BiConsumer;
/**
@@ -28,53 +20,12 @@ public enum ExceptionLoggers implements BiConsumer<Object, Throwable> {
E(Log.ERROR);
private static final String TAG = "WireGuard/" + ExceptionLoggers.class.getSimpleName();
-
private final int priority;
ExceptionLoggers(final int priority) {
this.priority = priority;
}
- public static Throwable unwrap(final Throwable throwable) {
- if (throwable instanceof CompletionException && throwable.getCause() != null)
- return throwable.getCause();
- if (throwable instanceof ParseException && throwable.getCause() != null)
- return throwable.getCause();
- return throwable;
- }
-
- public static String unwrapMessage(final Throwable throwable) {
- final Throwable innerThrowable = unwrap(throwable);
- final Resources resources = Application.get().getResources();
- String message;
- if (innerThrowable instanceof BadConfigException) {
- final BadConfigException configException = (BadConfigException) innerThrowable;
- message = resources.getString(R.string.parse_error, configException.getText(), configException.getLocation());
- final Throwable cause = unwrap(configException);
- if (cause.getMessage() != null)
- message += ": " + cause.getMessage();
- } else if (innerThrowable instanceof KeyFormatException) {
- final KeyFormatException keyFormatException = (KeyFormatException) innerThrowable;
- switch (keyFormatException.getFormat()) {
- case BASE64:
- message = resources.getString(R.string.key_length_base64_exception_message);
- break;
- case BINARY:
- message = resources.getString(R.string.key_length_exception_message);
- break;
- case HEX:
- message = resources.getString(R.string.key_length_hex_exception_message);
- break;
- default:
- // Will never happen, as getFormat is not nullable.
- message = null;
- }
- } else {
- message = innerThrowable.getMessage();
- }
- return message != null ? message : innerThrowable.getClass().getSimpleName();
- }
-
@Override
public void accept(final Object result, @Nullable final Throwable throwable) {
if (throwable != null)