001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.util.cli;
028    
029    
030    
031    import org.opends.messages.Message;
032    import org.opends.messages.UtilityMessages;
033    import org.opends.server.types.IdentifiedException;
034    
035    
036    
037    /**
038     * Thrown to indicate that a problem occurred when interacting with
039     * the client. For example, if input provided by the client was
040     * invalid.
041     */
042    public class CLIException extends IdentifiedException {
043    
044      /**
045       * Serialization ID.
046       */
047      private static final long serialVersionUID = -8182075627986981748L;
048    
049    
050    
051      /**
052       * Adapts any exception that may have occurred whilst reading input
053       * from the console.
054       *
055       * @param cause
056       *          The exception that occurred whilst reading input from
057       *          the console.
058       * @return Returns a new CLI exception describing a problem that
059       *         occurred whilst reading input from the console.
060       */
061      public static CLIException adaptInputException(Throwable cause) {
062        return new CLIException(UtilityMessages.ERR_CONSOLE_INPUT_ERROR.get(cause
063            .getMessage()), cause);
064      }
065    
066    
067    
068      /**
069       * Creates a new CLI exception with the provided message.
070       *
071       * @param message
072       *          The message explaining the problem that occurred.
073       */
074      public CLIException(Message message) {
075        super(message);
076      }
077    
078    
079    
080      /**
081       * Creates a new CLI exception with the provided message and cause.
082       *
083       * @param message
084       *          The message explaining the problem that occurred.
085       * @param cause
086       *          The cause of this exception.
087       */
088      public CLIException(Message message, Throwable cause) {
089        super(message, cause);
090      }
091    
092    }