    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.net.telnet;
    019
    020/**
    021 * The InvalidTelnetOptionException is the exception that is thrown whenever a TelnetOptionHandler with an invlaid option code is registered in TelnetClient
    022 * with addOptionHandler.
    023 */
    024public class InvalidTelnetOptionException extends Exception {
    025
    026    private static final long serialVersionUID = -2516777155928793597L;
    027
    028    /**
    029     * Option code
    030     */
    031    private final int optionCode;
    032
    033    /**
    034     * Error message
    035     */
    036    private final String msg;
    037
    038    /**
    039     * Constructor for the exception.
    040     *
    041     * @param message   Error message.
    042     * @param optcode   Option code.
    043     */
    044    public InvalidTelnetOptionException(final String message, final int optcode) {
    045        optionCode = optcode;
    046        msg = message;
    047    }
    048
    049    /**
    050     * Gets the error message of the exception.
    051     *
    052     * @return the error message.
    053     */
    054    @Override
    055    public String getMessage() {
    056        return msg + ": " + optionCode;
    057    }
    058}