1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.cli.processor;
7   
8   import org.apache.commons.cli.Option;
9   import org.apache.commons.cli.ParseException;
10  
11  import edu.umd.cs.findbugs.annotations.NonNull;
12  import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13  
14  /**
15   * Thrown when an option argument is found to be invalid during parsing of a
16   * command-line.
17   */
18  public class InvalidArgumentException
19      extends ParseException {
20  
21    /**
22     * the serial version UID.
23     */
24    private static final long serialVersionUID = 1L;
25  
26    /** The option that had the invalid argument. */
27    private Option option;
28  
29    /**
30     * Generate a new exception.
31     *
32     * @param message
33     *          the message
34     */
35    public InvalidArgumentException(String message) {
36      super(message);
37    }
38  
39    /**
40     * Return the option requiring an argument that wasn't provided on the command
41     * line.
42     *
43     * @return the related option
44     */
45    @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "intended to expose option for error handling")
46    public Option getOption() {
47      return option;
48    }
49  
50    /**
51     * Assign the option requiring an argument that wasn't provided on the command
52     * line.
53     *
54     * @param option
55     *          the option to set
56     */
57    @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "intended to expose option for error handling")
58    public void setOption(@NonNull Option option) {
59      this.option = option;
60    }
61  }