summaryrefslogtreecommitdiffstats
path: root/args4j/args4j/src/org/kohsuke/args4j/CmdLineException.java
blob: 7151801bfcd3e596af63142bced01965413c86fc (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.kohsuke.args4j;

import org.kohsuke.args4j.spi.OptionHandler;

/**
 * Signals an error in the user input.
 *
 * @author Kohsuke Kawaguchi
 */
public class CmdLineException extends Exception {
	private static final long serialVersionUID = -8574071211991372980L;

    private CmdLineParser parser;

    /**
     * @deprecated
     *      Use {@link #CmdLineException(CmdLineParser, String)}
     */
    public CmdLineException(String message) {
        super(message);
    }

    /**
     * @deprecated
     *      Use {@link #CmdLineException(CmdLineParser, String, Throwable)}
     */
    public CmdLineException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * @deprecated
     *      Use {@link #CmdLineException(CmdLineParser, Throwable)}
     */
    public CmdLineException(Throwable cause) {
        super(cause);
    }

    public CmdLineException(CmdLineParser parser, String message) {
        super(message);
        this.parser = parser;
    }

    public CmdLineException(CmdLineParser parser, String message, Throwable cause) {
        super(message, cause);
        this.parser = parser;
    }

    public CmdLineException(CmdLineParser parser, Throwable cause) {
        super(cause);
        this.parser = parser;
    }

    /**
     * Obtains the {@link CmdLineParser} that triggered an exception.
     *
     * <p>
     * Unless you have legacy {@link OptionHandler} that doesn't pass in this information
     * when it throws an exception, this method should always return a non-null value. a
     */
    public CmdLineParser getParser() {
        return parser;
    }
}