001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package gov.nist.secauto.metaschema.cli.processor; 007 008import org.apache.commons.cli.Option; 009import org.apache.commons.cli.ParseException; 010 011import edu.umd.cs.findbugs.annotations.NonNull; 012import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 013 014/** 015 * Thrown when an option argument is found to be invalid during parsing of a 016 * command-line. 017 */ 018public class InvalidArgumentException 019 extends ParseException { 020 021 /** 022 * the serial version UID. 023 */ 024 private static final long serialVersionUID = 1L; 025 026 /** The option that had the invalid argument. */ 027 private Option option; 028 029 /** 030 * Generate a new exception. 031 * 032 * @param message 033 * the message 034 */ 035 public InvalidArgumentException(String message) { 036 super(message); 037 } 038 039 /** 040 * Return the option requiring an argument that wasn't provided on the command 041 * line. 042 * 043 * @return the related option 044 */ 045 @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "intended to expose option for error handling") 046 public Option getOption() { 047 return option; 048 } 049 050 /** 051 * Assign the option requiring an argument that wasn't provided on the command 052 * line. 053 * 054 * @param option 055 * the option to set 056 */ 057 @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "intended to expose option for error handling") 058 public void setOption(@NonNull Option option) { 059 this.option = option; 060 } 061}