diff options
author | Samuel Holland <samuel@sholland.org> | 2018-12-15 14:45:14 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-12-15 14:46:23 -0600 |
commit | 2e8d566bd42ac747ad276eb5e328ee2303c48c26 (patch) | |
tree | 50cd35a1bc93e6668a9db982af50b7e5b70c6e1e /app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java | |
parent | dcb0e9b3e8643bc73a67c874b9add72cc0ee8f6e (diff) |
Clean up error messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
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.java | 49 |
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) |