001    /*
002     *  Copyright 2004 The Apache Software Foundation
003     *
004     *  Licensed under the Apache License, Version 2.0 (the "License");
005     *  you may not use this file except in compliance with the License.
006     *  You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     *  Unless required by applicable law or agreed to in writing, software
011     *  distributed under the License is distributed on an "AS IS" BASIS,
012     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     *  See the License for the specific language governing permissions and
014     *  limitations under the License.
015     */
016    package org.apache.commons.convert;
017    
018    /**
019     * ConversionException is used when a conversion has failed for some reason.
020     *
021     * @author Craig McClanahan
022     * @author Paulo Gaspar
023     * @author Stephen Colebourne
024     * @version $Id: ConversionException.java 155441 2005-02-26 13:19:22Z dirkv $
025     * @since 1.0
026     */
027    public class ConversionException extends IllegalArgumentException {
028    
029        /**
030         * The root cause of this <code>ConversionException</code>, compatible with
031         * JDK 1.4's extensions to <code>java.lang.Throwable</code>.
032         */
033        protected Throwable cause;
034        
035        /**
036         * Construct a new exception with the specified message.
037         *
038         * @param message  a message describing this exception
039         */
040        public ConversionException(String message) {
041            super(message);
042        }
043    
044        /**
045         * Construct a new exception with the specified root cause.
046         *
047         * @param cause  the root cause of this exception
048         */
049        public ConversionException(Throwable cause) {
050            super(cause.getMessage());
051            this.cause = cause;
052        }
053    
054        /**
055         * Construct a new exception with the specified message and root cause.
056         *
057         * @param message  a message describing this exception
058         * @param cause  the root cause of this exception
059         */
060        public ConversionException(String message, Throwable cause) {
061            super(message);
062            this.cause = cause;
063        }
064    
065        /**
066         * Gets the root cause of the exception.
067         * 
068         * @return the root cause
069         */
070        public Throwable getCause() {
071            return cause;
072        }
073    
074    }