diff options
author | Samuel Holland <samuel@sholland.org> | 2018-12-13 21:30:38 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-12-15 14:46:23 -0600 |
commit | dcb0e9b3e8643bc73a67c874b9add72cc0ee8f6e (patch) | |
tree | e0f720a7315a60827d19daa8ee155f09eab61586 /app/src/main/java/com/wireguard/crypto/KeyFormatException.java | |
parent | Bump the go runtime (diff) | |
download | wireguard-android-dcb0e9b3e8643bc73a67c874b9add72cc0ee8f6e.tar.xz wireguard-android-dcb0e9b3e8643bc73a67c874b9add72cc0ee8f6e.zip |
Provide semantically meaningful exceptions for translation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/crypto/KeyFormatException.java')
-rw-r--r-- | app/src/main/java/com/wireguard/crypto/KeyFormatException.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/crypto/KeyFormatException.java b/app/src/main/java/com/wireguard/crypto/KeyFormatException.java new file mode 100644 index 00000000..b44297d1 --- /dev/null +++ b/app/src/main/java/com/wireguard/crypto/KeyFormatException.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2018 WireGuard LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.crypto; + +/** + * An exception thrown when attempting to parse an invalid key (too short, too long, or byte + * data inappropriate for the format). The format being parsed can be accessed with the + * {@link #getFormat} method. + */ +public final class KeyFormatException extends Exception { + private final Key.Format format; + private final Type type; + + KeyFormatException(final Key.Format format, final Type type) { + this.format = format; + this.type = type; + } + + public Key.Format getFormat() { + return format; + } + + public Type getType() { + return type; + } + + public enum Type { + CONTENTS, + LENGTH + } +} |