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    
018    package org.apache.commons.dbcp;
019    
020    
021    /**
022     * <p>Subclass of <code>RuntimeException</code> that can be used to wrap
023     * a <code>SQLException</code> using the "root cause" pattern of JDK 1.4
024     * exceptions, but without requiring a 1.4 runtime environment.</p>
025     *
026     * @author Jonathan Fuerth
027     * @author Dan Fraser
028     * @version $Revision: 892307 $ $Date: 2013-12-31 23:27:28 +0000 (Tue, 31 Dec 2013) $
029     * 
030     * @deprecated This will be removed in a future version of DBCP.
031     **/
032    public class DbcpException extends RuntimeException {
033    
034        private static final long serialVersionUID = 2477800549022838103L;
035    
036        // ----------------------------------------------------------- Constructors
037    
038    
039        /**
040         * Construct a new runtime exception with <code>null</code> as its
041         * detail message.
042         */
043        public DbcpException() {
044    
045            super();
046    
047        }
048    
049    
050        /**
051         * Construct a new runtime exception with the specified detail message.
052         *
053         * @param message The detail message for this exception
054         */
055        public DbcpException(String message) {
056    
057            this(message, null);
058    
059        }
060    
061    
062        /**
063         * Construct a new runtime exception with the specified detail message
064         * and cause.
065         *
066         * @param message The detail message for this exception
067         * @param cause The root cause for this exception
068         */
069        public DbcpException(String message, Throwable cause) {
070    
071            super(message);
072            this.cause = cause;
073    
074        }
075    
076    
077        /**
078         * Construct a new runtime exception with the specified cause and a
079         * detail message of <code>(cause == null &#63; null : cause&#46;toString())</code>.
080         *
081         * @param cause The root cause for this exception
082         */
083        public DbcpException(Throwable cause) {
084    
085            super((cause == null) ? (String) null : cause.toString());
086            this.cause = cause;
087    
088        }
089    
090    
091        // ----------------------------------------------------- Instance Variables
092    
093    
094        /**
095         * The root cause of this exception (typically an
096         * <code>SQLException</code> but this is not required).
097         */
098        protected Throwable cause = null;
099    
100    
101        // --------------------------------------------------------- Public Methods
102    
103    
104        /**
105         * Return the root cause of this exception (if any).
106         */
107        public Throwable getCause() {
108    
109            return (this.cause);
110    
111        }
112    
113    
114    }