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.io;
019    
020    import java.io.IOException;
021    
022    /**
023     * Subclasses IOException with the {@link Throwable} constructors missing before Java 6. If you are using Java 6,
024     * consider this class deprecated and use {@link IOException}.
025     * 
026     * @author <a href="http://commons.apache.org/io/">Apache Commons IO</a>
027     * @version $Id: IOExceptionWithCause.java 651569 2008-04-25 10:42:55Z niallp $
028     * @since Commons IO 1.4
029     */
030    public class IOExceptionWithCause extends IOException {
031    
032        /**
033         * Defines the serial version UID.
034         */
035        private static final long serialVersionUID = 1L;
036    
037        /**
038         * Constructs a new instance with the given message and cause.
039         * <p>
040         * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's
041         * message.
042         * </p>
043         * 
044         * @param message
045         *            the message (see {@link #getMessage()})
046         * @param cause
047         *            the cause (see {@link #getCause()}). A <code>null</code> value is allowed.
048         */
049        public IOExceptionWithCause(String message, Throwable cause) {
050            super(message);
051            this.initCause(cause);
052        }
053    
054        /**
055         * Constructs a new instance with the given cause.
056         * <p>
057         * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class
058         * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable.
059         * </p>
060         * 
061         * @param cause
062         *            the cause (see {@link #getCause()}). A <code>null</code> value is allowed.
063         */
064        public IOExceptionWithCause(Throwable cause) {
065            super(cause == null ? null : cause.toString());
066            this.initCause(cause);
067        }
068    
069    }