    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 *      http://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     * <p>
    041     *
    042     * @param message - Error message.
    043     * @param optcode - Option code.
    044     */
    045    public InvalidTelnetOptionException(final String message, final int optcode) {
    046        optionCode = optcode;
    047        msg = message;
    048    }
    049
    050    /**
    051     * Gets the error message of ths exception.
    052     * <p>
    053     *
    054     * @return the error message.
    055     */
    056    @Override
    057    public String getMessage() {
    058        return msg + ": " + optionCode;
    059    }
    060}