diff options
Diffstat (limited to 'app/src/main/java/com/wireguard/config/ParseException.java')
-rw-r--r-- | app/src/main/java/com/wireguard/config/ParseException.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/config/ParseException.java b/app/src/main/java/com/wireguard/config/ParseException.java new file mode 100644 index 00000000..1fccb534 --- /dev/null +++ b/app/src/main/java/com/wireguard/config/ParseException.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2018 WireGuard LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.config; + +/** + * An exception representing a failure to parse an element of a WireGuard configuration. The context + * for this failure can be retrieved with {@link #getContext}, and the text that failed to parse can + * be retrieved with {@link #getText}. + */ +public class ParseException extends Exception { + private final String context; + private final CharSequence text; + + public ParseException(final String context, final CharSequence text, final String message) { + super(message); + this.context = context; + this.text = text; + } + + public ParseException(final String context, final CharSequence text, final Throwable cause) { + super(cause.getMessage(), cause); + this.context = context; + this.text = text; + } + + public ParseException(final String context, final CharSequence text) { + this.context = context; + this.text = text; + } + + public String getContext() { + return context; + } + + public CharSequence getText() { + return text; + } +} |