aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/config/ParseException.java
blob: 1fccb534121eabed0afcd245de20bedf0ae5cc8e (plain) (blame)
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
/*
 * 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;
    }
}