001/**
002 * Copyright 2017, Digi International Inc.
003 *
004 * This Source Code Form is subject to the terms of the Mozilla Public
005 * License, v. 2.0. If a copy of the MPL was not distributed with this
006 * file, you can obtain one at http://mozilla.org/MPL/2.0/.
007 *
008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 
009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 
010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 
011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
015 */
016package com.digi.xbee.api.exceptions;
017
018import com.digi.xbee.api.models.OperatingMode;
019
020/**
021 * This exception will be thrown when performing any action with the XBee 
022 * device and its operating mode is different than {@link OperatingMode#API} 
023 * and {@link OperatingMode#API_ESCAPE}.
024 * 
025 * @see XBeeDeviceException
026 * @see com.digi.xbee.api.models.OperatingMode
027 */
028public class InvalidOperatingModeException extends XBeeDeviceException {
029
030        // Constants
031        private static final long serialVersionUID = 1L;
032        private static final String DEFAULT_MESSAGE = "The operating mode of the XBee device is not supported by the library.";
033
034        /**
035         * Creates an {@code InvalidOperatingModeException} with 
036         * {@value #DEFAULT_MESSAGE} as its error detail message.
037         */
038        public InvalidOperatingModeException() {
039                super(DEFAULT_MESSAGE);
040        }
041        
042        /**
043         * Creates an {@code InvalidOperatingModeException} with the specified
044         * operating mode.
045         * 
046         * @param mode The unsupported operating mode.
047         * 
048         * @see com.digi.xbee.api.models.OperatingMode
049         */
050        public InvalidOperatingModeException(OperatingMode mode) {
051                super("Unsupported operating mode: " + mode);
052        }
053        
054        /**
055         * Creates an {@code InvalidOperatingModeException} with the specified 
056         * message.
057         * 
058         * @param message The associated message.
059         */
060        public InvalidOperatingModeException(String message) {
061                super(message);
062        }
063        
064        /**
065         * Creates an {@code InvalidOperatingModeException} with the specified 
066         * message and cause.
067         * 
068         * @param message The associated message.
069         * @param cause The cause of this exception.
070         * 
071         * @see Throwable
072         */
073        public InvalidOperatingModeException(String message, Throwable cause) {
074                super(message, cause);
075        }
076}