    001/*
    002  Licensed to the Apache Software Foundation (ASF) under one or more
    003  contributor license agreements.  See the NOTICE file distributed with
    004  this work for additional information regarding copyright ownership.
    005  The ASF licenses this file to You under the Apache License, Version 2.0
    006  (the "License"); you may not use this file except in compliance with
    007  the License.  You may obtain a copy of the License at
    008
    009      https://www.apache.org/licenses/LICENSE-2.0
    010
    011  Unless required by applicable law or agreed to in writing, software
    012  distributed under the License is distributed on an "AS IS" BASIS,
    013  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014  See the License for the specific language governing permissions and
    015  limitations under the License.
    016 */
    017
    018package org.apache.commons.cli;
    019
    020/**
    021 * Thrown during parsing signaling an unrecognized option.
    022 */
    023public class UnrecognizedOptionException extends ParseException {
    024
    025    /**
    026     * This exception {@code serialVersionUID}.
    027     */
    028    private static final long serialVersionUID = -252504690284625623L;
    029
    030    /** The unrecognized option. */
    031    private final String option;
    032
    033    /**
    034     * Constructs a new {@code UnrecognizedArgumentException} with the specified detail message.
    035     *
    036     * @param message the detail message.
    037     */
    038    public UnrecognizedOptionException(final String message) {
    039        this(message, null);
    040    }
    041
    042    /**
    043     * Constructs a new {@code UnrecognizedArgumentException} with the specified option and detail message.
    044     *
    045     * @param message the detail message.
    046     * @param option the unrecognized option.
    047     * @since 1.2
    048     */
    049    public UnrecognizedOptionException(final String message, final String option) {
    050        super(message);
    051        this.option = option;
    052    }
    053
    054    /**
    055     * Gets the unrecognized option.
    056     *
    057     * @return the related option.
    058     * @since 1.2
    059     */
    060    public String getOption() {
    061        return option;
    062    }
    063}