• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // Copyright 2014 The Bazel Authors. All rights reserved.
2  //
3  // Licensed under the Apache License, Version 2.0 (the "License");
4  // you may not use this file except in compliance with the License.
5  // You may obtain a copy of the License at
6  //
7  //    http://www.apache.org/licenses/LICENSE-2.0
8  //
9  // Unless required by applicable law or agreed to in writing, software
10  // distributed under the License is distributed on an "AS IS" BASIS,
11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  // See the License for the specific language governing permissions and
13  // limitations under the License.
14  
15  package com.google.devtools.common.options;
16  
17  /**
18   * An exception that's thrown when the {@link OptionsParser} fails.
19   *
20   * @see OptionsParser#parse(OptionPriority,String,java.util.List)
21   */
22  public class OptionsParsingException extends Exception {
23    private final String invalidArgument;
24  
OptionsParsingException(String message)25    public OptionsParsingException(String message) {
26      this(message, (String) null);
27    }
28  
OptionsParsingException(String message, String argument)29    public OptionsParsingException(String message, String argument) {
30      super(message);
31      this.invalidArgument = argument;
32    }
33  
OptionsParsingException(String message, Throwable throwable)34    public OptionsParsingException(String message, Throwable throwable) {
35      this(message, null, throwable);
36    }
37  
OptionsParsingException(String message, String argument, Throwable throwable)38    public OptionsParsingException(String message, String argument, Throwable throwable) {
39      super(message, throwable);
40      this.invalidArgument = argument;
41    }
42  
43    /**
44     * Gets the name of the invalid argument or {@code null} if the exception
45     * can not determine the exact invalid arguments
46     */
getInvalidArgument()47    public String getInvalidArgument() {
48      return invalidArgument;
49    }
50  }
51